diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index e0b3826..f0167d5 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -39,7 +39,7 @@ class TimelogController < ApplicationController def index sort_init 'spent_on', 'desc' - sort_update 'spent_on' => 'spent_on', + sort_update 'spent_on' => ['spent_on', "#{TimeEntry.table_name}.created_on"], 'user' => 'user_id', 'activity' => 'activity_id', 'project' => "#{Project.table_name}.name", diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 781c5d6..bd627d6 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -10,6 +10,7 @@ http://www.redmine.org/ * Defect #11061: Cannot choose commit versions to view differences in Git/Mercurial repository view * Defect #11112: REST API - custom fields in POST/PUT ignored for time_entries * Defect #11133: Wiki-page section edit link can point to incorrect section +* Defect #11178: Spent time sorted by date-descending order lists same-date entries in physical order * Feature #6597: Configurable session lifetime and timeout * Patch #11113: Small glitch in German localization diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index 10f5ccd..7a0d0f5 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -550,6 +550,20 @@ class TimelogControllerTest < ActionController::TestCase :attributes => {:action => "/projects/ecookbook/issues/1/time_entries", :id => 'query_form'} end + def test_index_should_sort_by_spent_on_and_created_on + t1 = TimeEntry.create!(:user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-16', :created_on => '2012-06-16 20:00:00', :activity_id => 10) + t2 = TimeEntry.create!(:user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-16', :created_on => '2012-06-16 20:05:00', :activity_id => 10) + t3 = TimeEntry.create!(:user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-15', :created_on => '2012-06-16 20:10:00', :activity_id => 10) + + get :index, :project_id => 1, :from => '2012-06-15', :to => '2012-06-16' + assert_response :success + assert_equal [t2, t1, t3], assigns(:entries) + + get :index, :project_id => 1, :from => '2012-06-15', :to => '2012-06-16', :sort => 'spent_on' + assert_response :success + assert_equal [t3, t1, t2], assigns(:entries) + end + def test_index_atom_feed get :index, :project_id => 1, :format => 'atom' assert_response :success