Defect #33952 » 33952-v2.patch
| app/models/time_entry_query.rb | ||
|---|---|---|
| 25 | 25 |
QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true),
|
| 26 | 26 |
QueryColumn.new(:spent_on, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :default_order => 'desc', :groupable => true),
|
| 27 | 27 |
TimestampQueryColumn.new(:created_on, :sortable => "#{TimeEntry.table_name}.created_on", :default_order => 'desc', :groupable => true),
|
| 28 |
QueryColumn.new(:tweek, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :caption => :label_week),
|
|
| 28 |
QueryColumn.new(:tweek, :sortable => ["#{TimeEntry.table_name}.tyear", "#{TimeEntry.table_name}.tweek"], :caption => :label_week),
|
|
| 29 | 29 |
QueryColumn.new(:author, :sortable => lambda {User.fields_for_order_statement}),
|
| 30 | 30 |
QueryColumn.new(:user, :sortable => lambda {User.fields_for_order_statement}, :groupable => true),
|
| 31 | 31 |
QueryColumn.new(:activity, :sortable => "#{TimeEntryActivity.table_name}.position", :groupable => true),
|
| test/functional/timelog_controller_test.rb | ||
|---|---|---|
| 1184 | 1184 |
) |
| 1185 | 1185 |
end |
| 1186 | 1186 | |
| 1187 |
def test_index_should_sort_by_tweek_and_spent_on |
|
| 1188 |
t1 = TimeEntry.generate!(:spent_on => '2012-06-10') # tyear:2012, tweek:23 |
|
| 1189 |
t2 = TimeEntry.generate!(:spent_on => '2012-06-11') # tyear:2012, tweek:24 |
|
| 1190 |
t3 = TimeEntry.generate!(:spent_on => '2012-06-12') # tyear:2012, tweek:24 |
|
| 1191 |
t4 = TimeEntry.generate!(:spent_on => '2013-06-12') # tyear:2013, tweek:24 |
|
| 1192 | ||
| 1193 |
params = {
|
|
| 1194 |
:project_id => 1, |
|
| 1195 |
:f => ['spent_on'], |
|
| 1196 |
:op => {'spent_on' => '><'},
|
|
| 1197 |
:v => {'spent_on' => ['2012-06-10', '2013-06-12']}
|
|
| 1198 |
} |
|
| 1199 | ||
| 1200 |
[ |
|
| 1201 |
[{:sort => 'tweek,spent_on'}, [t1, t2, t3, t4]],
|
|
| 1202 |
[{:sort => 'tweek,spent_on:desc'}, [t1, t3, t2, t4]],
|
|
| 1203 |
[{:sort => 'tweek:desc,spent_on'}, [t4, t2, t3, t1]],
|
|
| 1204 |
[{:sort => 'tweek:desc,spent_on:desc'}, [t4, t3, t2, t1]],
|
|
| 1205 |
].each do |sort_criteria, expected| |
|
| 1206 |
get :index, :params => params.dup.merge(sort_criteria) |
|
| 1207 |
assert_response :success |
|
| 1208 |
expected_ids = expected.map(&:id).map(&:to_s) |
|
| 1209 |
actual_ids = css_select('input[name="ids[]"]').map {|e| e.attr('value')}
|
|
| 1210 |
assert_equal expected_ids, actual_ids |
|
| 1211 |
end |
|
| 1212 |
end |
|
| 1213 | ||
| 1187 | 1214 |
def test_index_with_activity_filter |
| 1188 | 1215 |
activity = TimeEntryActivity.create!(:name => 'Activity') |
| 1189 | 1216 |
entry = TimeEntry.generate!(:issue_id => 1, :hours => 4.5, :activity => activity) |
- « Previous
- 1
- 2
- 3
- 4
- Next »