Defect #33912 » fixed-33912.patch
app/models/time_entry_query.rb | ||
---|---|---|
23 | 23 | |
24 | 24 |
self.available_columns = [ |
25 | 25 |
QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true), |
26 |
QueryColumn.new(:spent_on, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :default_order => 'desc', :groupable => true),
|
|
26 |
QueryColumn.new(:spent_on, :sortable => "#{TimeEntry.table_name}.spent_on", :default_order => 'desc', :groupable => true),
|
|
27 | 27 |
TimestampQueryColumn.new(:created_on, :sortable => "#{TimeEntry.table_name}.created_on", :default_order => 'desc', :groupable => true), |
28 | 28 |
QueryColumn.new(:tweek, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :caption => :label_week), |
29 | 29 |
QueryColumn.new(:author, :sortable => lambda {User.fields_for_order_statement}), |
... | ... | |
152 | 152 |
def results_scope(options={}) |
153 | 153 |
order_option = [group_by_sort_order, (options[:order] || sort_clause)].flatten.reject(&:blank?) |
154 | 154 | |
155 |
order_option << "#{TimeEntry.table_name}.id ASC" |
|
155 |
order_option << |
|
156 |
if order_option.reverse.find{|order| order.match?(/#{TimeEntry.table_name}\./)}&.match?(/\sDESC$/i) |
|
157 |
"#{TimeEntry.table_name}.id DESC" |
|
158 |
else |
|
159 |
"#{TimeEntry.table_name}.id ASC" |
|
160 |
end |
|
156 | 161 |
base_scope. |
157 | 162 |
order(order_option). |
158 | 163 |
joins(joins_for_order_statement(order_option.join(','))) |
test/functional/timelog_controller_test.rb | ||
---|---|---|
1128 | 1128 |
assert_equal [t3, t1, t2].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')} |
1129 | 1129 |
end |
1130 | 1130 | |
1131 |
def test_index_should_sort_by_spent_on_and_user |
|
1132 |
user1 = User.find(1) # Redmine Admin |
|
1133 |
user2 = User.find(2) # John Smith |
|
1134 |
t1 = TimeEntry.generate!(:spent_on => '2012-06-16', :user => user2) |
|
1135 |
t2 = TimeEntry.generate!(:spent_on => '2012-06-16', :user => user1) |
|
1136 |
t3 = TimeEntry.generate!(:spent_on => '2012-06-15', :user => user2) |
|
1137 | ||
1138 |
params = { |
|
1139 |
:project_id => 1, |
|
1140 |
:f => ['spent_on'], |
|
1141 |
:op => {'spent_on' => '><'}, |
|
1142 |
:v => {'spent_on' => ['2012-06-15', '2012-06-16']} |
|
1143 |
} |
|
1144 | ||
1145 |
[ |
|
1146 |
[{:sort => 'spent_on,user'}, [t3, t1, t2]], |
|
1147 |
[{:sort => 'spent_on,user:desc'}, [t3, t2, t1]], |
|
1148 |
[{:sort => 'spent_on:desc,user'}, [t1, t2, t3]], |
|
1149 |
[{:sort => 'spent_on:desc,user:desc'}, [t2, t1, t3]], |
|
1150 |
].each do |sort_criteria, expect| |
|
1151 |
get :index, :params => params.dup.merge(sort_criteria) |
|
1152 |
assert_response :success |
|
1153 |
assert_equal expect.map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')} |
|
1154 |
end |
|
1155 |
end |
|
1156 | ||
1131 | 1157 |
def test_index_with_activity_filter |
1132 | 1158 |
activity = TimeEntryActivity.create!(:name => 'Activity') |
1133 | 1159 |
entry = TimeEntry.generate!(:issue_id => 1, :hours => 4.5, :activity => activity) |
- « Previous
- 1
- 2
- 3
- Next »