mirror of
https://github.com/redmine/redmine.git
synced 2025-11-14 17:26:06 +01:00
Spent time details are displayed in incorrect order when sorted by week and date (#33952).
Patch by Yuichi HARADA. git-svn-id: http://svn.redmine.org/redmine/trunk@20634 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -25,7 +25,7 @@ class TimeEntryQuery < Query
|
|||||||
QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true),
|
QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true),
|
||||||
QueryColumn.new(:spent_on, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :default_order => 'desc', :groupable => true),
|
QueryColumn.new(:spent_on, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :default_order => 'desc', :groupable => true),
|
||||||
TimestampQueryColumn.new(:created_on, :sortable => "#{TimeEntry.table_name}.created_on", :default_order => 'desc', :groupable => true),
|
TimestampQueryColumn.new(:created_on, :sortable => "#{TimeEntry.table_name}.created_on", :default_order => 'desc', :groupable => true),
|
||||||
QueryColumn.new(:tweek, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :caption => :label_week),
|
QueryColumn.new(:tweek, :sortable => ["#{TimeEntry.table_name}.tyear", "#{TimeEntry.table_name}.tweek"], :caption => :label_week),
|
||||||
QueryColumn.new(:author, :sortable => lambda {User.fields_for_order_statement}),
|
QueryColumn.new(:author, :sortable => lambda {User.fields_for_order_statement}),
|
||||||
QueryColumn.new(:user, :sortable => lambda {User.fields_for_order_statement}, :groupable => true),
|
QueryColumn.new(:user, :sortable => lambda {User.fields_for_order_statement}, :groupable => true),
|
||||||
QueryColumn.new(:activity, :sortable => "#{TimeEntryActivity.table_name}.position", :groupable => true),
|
QueryColumn.new(:activity, :sortable => "#{TimeEntryActivity.table_name}.position", :groupable => true),
|
||||||
|
|||||||
@@ -1184,6 +1184,33 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_index_should_sort_by_tweek_and_spent_on
|
||||||
|
t1 = TimeEntry.generate!(:spent_on => '2012-06-10') # tyear:2012, tweek:23
|
||||||
|
t2 = TimeEntry.generate!(:spent_on => '2012-06-11') # tyear:2012, tweek:24
|
||||||
|
t3 = TimeEntry.generate!(:spent_on => '2012-06-12') # tyear:2012, tweek:24
|
||||||
|
t4 = TimeEntry.generate!(:spent_on => '2013-06-12') # tyear:2013, tweek:24
|
||||||
|
|
||||||
|
params = {
|
||||||
|
:project_id => 1,
|
||||||
|
:f => ['spent_on'],
|
||||||
|
:op => {'spent_on' => '><'},
|
||||||
|
:v => {'spent_on' => ['2012-06-10', '2013-06-12']}
|
||||||
|
}
|
||||||
|
|
||||||
|
[
|
||||||
|
[{:sort => 'tweek,spent_on'}, [t1, t2, t3, t4]],
|
||||||
|
[{:sort => 'tweek,spent_on:desc'}, [t1, t3, t2, t4]],
|
||||||
|
[{:sort => 'tweek:desc,spent_on'}, [t4, t2, t3, t1]],
|
||||||
|
[{:sort => 'tweek:desc,spent_on:desc'}, [t4, t3, t2, t1]],
|
||||||
|
].each do |sort_criteria, expected|
|
||||||
|
get :index, :params => params.dup.merge(sort_criteria)
|
||||||
|
assert_response :success
|
||||||
|
expected_ids = expected.map(&:id).map(&:to_s)
|
||||||
|
actual_ids = css_select('input[name="ids[]"]').map {|e| e.attr('value')}
|
||||||
|
assert_equal expected_ids, actual_ids
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_index_with_activity_filter
|
def test_index_with_activity_filter
|
||||||
activity = TimeEntryActivity.create!(:name => 'Activity')
|
activity = TimeEntryActivity.create!(:name => 'Activity')
|
||||||
entry = TimeEntry.generate!(:issue_id => 1, :hours => 4.5, :activity => activity)
|
entry = TimeEntry.generate!(:issue_id => 1, :hours => 4.5, :activity => activity)
|
||||||
|
|||||||
Reference in New Issue
Block a user