@@ -39,7 +39,7 class TimelogController < ApplicationController | |||||
39 |
|
39 | |||
40 | def index |
|
40 | def index | |
41 | sort_init 'spent_on', 'desc' |
|
41 | sort_init 'spent_on', 'desc' | |
42 | sort_update 'spent_on' => 'spent_on', |
|
42 | sort_update 'spent_on' => ['spent_on', "#{TimeEntry.table_name}.created_on"], | |
43 | 'user' => 'user_id', |
|
43 | 'user' => 'user_id', | |
44 | 'activity' => 'activity_id', |
|
44 | 'activity' => 'activity_id', | |
45 | 'project' => "#{Project.table_name}.name", |
|
45 | 'project' => "#{Project.table_name}.name", |
@@ -568,6 +568,20 class TimelogControllerTest < ActionController::TestCase | |||||
568 | :attributes => {:action => "/projects/ecookbook/issues/1/time_entries", :id => 'query_form'} |
|
568 | :attributes => {:action => "/projects/ecookbook/issues/1/time_entries", :id => 'query_form'} | |
569 | end |
|
569 | end | |
570 |
|
570 | |||
|
571 | def test_index_should_sort_by_spent_on_and_created_on | |||
|
572 | 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) | |||
|
573 | 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) | |||
|
574 | 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) | |||
|
575 | ||||
|
576 | get :index, :project_id => 1, :from => '2012-06-15', :to => '2012-06-16' | |||
|
577 | assert_response :success | |||
|
578 | assert_equal [t2, t1, t3], assigns(:entries) | |||
|
579 | ||||
|
580 | get :index, :project_id => 1, :from => '2012-06-15', :to => '2012-06-16', :sort => 'spent_on' | |||
|
581 | assert_response :success | |||
|
582 | assert_equal [t3, t1, t2], assigns(:entries) | |||
|
583 | end | |||
|
584 | ||||
571 | def test_index_atom_feed |
|
585 | def test_index_atom_feed | |
572 | get :index, :project_id => 1, :format => 'atom' |
|
586 | get :index, :project_id => 1, :format => 'atom' | |
573 | assert_response :success |
|
587 | assert_response :success |
General Comments 0
You need to be logged in to leave comments.
Login now