diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/timelog_controller_test.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index e1236ffac..4163ce548 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -37,27 +37,39 @@ class TimelogControllerTest < Test::Unit::TestCase end def test_report_one_criteria - get :report, :project_id => 1, :period => "month", :date_from => "2007-01-01", :date_to => "2007-12-31", :criterias => ["member"] + get :report, :project_id => 1, :period => 'week', :date_from => "2007-04-01", :date_to => "2007-04-30", :criterias => ['project'] assert_response :success assert_template 'report' - assert_not_nil assigns(:hours) - end + assert_not_nil assigns(:total_hours) + assert_equal "8.65", "%.2f" % assigns(:total_hours) + end def test_report_two_criterias - get :report, :project_id => 1, :period => "week", :date_from => "2007-01-01", :date_to => "2007-12-31", :criterias => ["member", "activity"] + get :report, :project_id => 1, :period => 'month', :date_from => "2007-01-01", :date_to => "2007-12-31", :criterias => ["member", "activity"] assert_response :success assert_template 'report' - assert_not_nil assigns(:hours) + assert_not_nil assigns(:total_hours) + assert_equal "162.90", "%.2f" % assigns(:total_hours) end + def test_report_one_criteria_no_result + get :report, :project_id => 1, :period => 'week', :date_from => "1998-04-01", :date_to => "1998-04-30", :criterias => ['project'] + assert_response :success + assert_template 'report' + assert_not_nil assigns(:total_hours) + assert_equal "0.00", "%.2f" % assigns(:total_hours) + end + def test_details_at_project_level get :details, :project_id => 1 assert_response :success assert_template 'details' assert_not_nil assigns(:entries) - assert_equal 3, assigns(:entries).size + assert_equal 4, assigns(:entries).size + # project and subproject + assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort assert_not_nil assigns(:total_hours) - assert_equal 155.25, assigns(:total_hours) + assert_equal "162.90", "%.2f" % assigns(:total_hours) # display all time by default assert_nil assigns(:from) assert_nil assigns(:to) @@ -68,9 +80,9 @@ class TimelogControllerTest < Test::Unit::TestCase assert_response :success assert_template 'details' assert_not_nil assigns(:entries) - assert_equal 2, assigns(:entries).size + assert_equal 3, assigns(:entries).size assert_not_nil assigns(:total_hours) - assert_equal 5.25, assigns(:total_hours) + assert_equal "12.90", "%.2f" % assigns(:total_hours) assert_equal '2007-03-20'.to_date, assigns(:from) assert_equal '2007-04-30'.to_date, assigns(:to) end |