summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-08-31 16:34:54 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-08-31 16:34:54 +0000
commit696d21f8c8c88d487df46112082fcb1d9b5f6ec2 (patch)
tree5a4addd08ae94b062f042ae4de3bb1f18fce868e /test
parentdbad26c87db8247c0d635c993981d4277e165978 (diff)
downloadredmine-696d21f8c8c88d487df46112082fcb1d9b5f6ec2.tar.gz
redmine-696d21f8c8c88d487df46112082fcb1d9b5f6ec2.zip
Adds cross-project time reports support (#994).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1778 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/timelog_controller_test.rb54
1 files changed, 52 insertions, 2 deletions
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index 7b4622daa..28f2a28e2 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -78,7 +78,7 @@ class TimelogControllerTest < Test::Unit::TestCase
assert_equal 2, entry.user_id
end
- def destroy
+ def test_destroy
@request.session[:user_id] = 2
post :destroy, :id => 1
assert_redirected_to 'projects/ecookbook/timelog/details'
@@ -91,6 +91,29 @@ class TimelogControllerTest < Test::Unit::TestCase
assert_template 'report'
end
+ def test_report_all_projects
+ get :report
+ assert_response :success
+ assert_template 'report'
+ end
+
+ def test_report_all_projects_denied
+ r = Role.anonymous
+ r.permissions.delete(:view_time_entries)
+ r.permissions_will_change!
+ r.save
+ get :report
+ assert_redirected_to '/account/login'
+ end
+
+ def test_report_all_projects_one_criteria
+ get :report, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criterias => ['project']
+ assert_response :success
+ assert_template 'report'
+ assert_not_nil assigns(:total_hours)
+ assert_equal "8.65", "%.2f" % assigns(:total_hours)
+ end
+
def test_report_all_time
get :report, :project_id => 1, :criterias => ['project', 'issue']
assert_response :success
@@ -148,7 +171,18 @@ class TimelogControllerTest < Test::Unit::TestCase
assert_not_nil assigns(:total_hours)
assert_equal "0.00", "%.2f" % assigns(:total_hours)
end
-
+
+ def test_report_all_projects_csv_export
+ get :report, :columns => 'month', :from => "2007-01-01", :to => "2007-06-30", :criterias => ["project", "member", "activity"], :format => "csv"
+ assert_response :success
+ assert_equal 'text/csv', @response.content_type
+ lines = @response.body.chomp.split("\n")
+ # Headers
+ assert_equal 'Project,Member,Activity,2007-1,2007-2,2007-3,2007-4,2007-5,2007-6,Total', lines.first
+ # Total row
+ assert_equal 'Total,"","","","",154.25,8.65,"","",162.90', lines.last
+ end
+
def test_report_csv_export
get :report, :project_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-06-30", :criterias => ["project", "member", "activity"], :format => "csv"
assert_response :success
@@ -159,6 +193,14 @@ class TimelogControllerTest < Test::Unit::TestCase
# Total row
assert_equal 'Total,"","","","",154.25,8.65,"","",162.90', lines.last
end
+
+ def test_details_all_projects
+ get :details
+ assert_response :success
+ assert_template 'details'
+ assert_not_nil assigns(:total_hours)
+ assert_equal "162.90", "%.2f" % assigns(:total_hours)
+ end
def test_details_at_project_level
get :details, :project_id => 1
@@ -218,6 +260,14 @@ class TimelogControllerTest < Test::Unit::TestCase
assert assigns(:items).first.is_a?(TimeEntry)
end
+ def test_details_all_projects_csv_export
+ get :details, :format => 'csv'
+ assert_response :success
+ assert_equal 'text/csv', @response.content_type
+ assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n")
+ assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n")
+ end
+
def test_details_csv_export
get :details, :project_id => 1, :format => 'csv'
assert_response :success