From 200842ba5e753f342940d7df0f1cc342ae8485d4 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 27 Feb 2008 20:50:19 +0000 Subject: Propagates time tracking to the parent project (closes #433). Time report enhancements. git-svn-id: http://redmine.rubyforge.org/svn/trunk@1176 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/fixtures/time_entries.yml | 21 ++++++++++++++++++--- test/functional/timelog_controller_test.rb | 30 +++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/fixtures/time_entries.yml b/test/fixtures/time_entries.yml index ae2b1efea..151077d2b 100644 --- a/test/fixtures/time_entries.yml +++ b/test/fixtures/time_entries.yml @@ -6,7 +6,7 @@ time_entries_001: project_id: 1 comments: My hours updated_on: 2007-03-23 12:54:18 +01:00 - activity_id: 8 + activity_id: 9 spent_on: 2007-03-23 issue_id: 1 id: 1 @@ -20,7 +20,7 @@ time_entries_002: project_id: 1 comments: "" updated_on: 2007-03-23 14:11:04 +01:00 - activity_id: 8 + activity_id: 9 spent_on: 2007-03-12 issue_id: 1 id: 2 @@ -34,10 +34,25 @@ time_entries_003: project_id: 1 comments: "" updated_on: 2007-04-21 12:20:48 +02:00 - activity_id: 8 + activity_id: 9 spent_on: 2007-04-21 issue_id: 2 id: 3 hours: 1.0 user_id: 1 tyear: 2007 +time_entries_004: + created_on: 2007-04-22 12:20:48 +02:00 + tweek: 16 + tmonth: 4 + project_id: 3 + comments: Time spent on a subproject + updated_on: 2007-04-22 12:20:48 +02:00 + activity_id: 10 + spent_on: 2007-04-22 + issue_id: + id: 4 + hours: 7.65 + user_id: 1 + tyear: 2007 + \ No newline at end of file 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 -- cgit v1.2.3