comparison test/functional/reports_controller_test.rb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents cbb26bc654de
children 622f24f53b42 261b3d9a4903
comparison
equal deleted inserted replaced
929:5f33065ddc4b 1115:433d4f72a19b
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 require File.expand_path('../../test_helper', __FILE__) 18 require File.expand_path('../../test_helper', __FILE__)
19 require 'reports_controller'
20
21 # Re-raise errors caught by the controller.
22 class ReportsController; def rescue_action(e) raise e end; end
23
24 19
25 class ReportsControllerTest < ActionController::TestCase 20 class ReportsControllerTest < ActionController::TestCase
26 fixtures :projects, :trackers, :issue_statuses, :issues, 21 fixtures :projects, :trackers, :issue_statuses, :issues,
27 :enumerations, :users, :issue_categories, 22 :enumerations, :users, :issue_categories,
28 :projects_trackers, 23 :projects_trackers,
32 :enabled_modules, 27 :enabled_modules,
33 :workflows, 28 :workflows,
34 :versions 29 :versions
35 30
36 def setup 31 def setup
37 @controller = ReportsController.new
38 @request = ActionController::TestRequest.new
39 @response = ActionController::TestResponse.new
40 User.current = nil
41 end 32 end
42 33
43 context "GET :issue_report without details" do 34 def test_get_issue_report
44 setup do 35 get :issue_report, :id => 1
45 get :issue_report, :id => 1 36
37 assert_response :success
38 assert_template 'issue_report'
39
40 [:issues_by_tracker, :issues_by_version, :issues_by_category, :issues_by_assigned_to,
41 :issues_by_author, :issues_by_subproject, :issues_by_priority].each do |ivar|
42 assert_not_nil assigns(ivar)
46 end 43 end
47 44
48 should_respond_with :success 45 assert_equal IssuePriority.all.reverse, assigns(:priorities)
49 should_render_template :issue_report 46 end
50 47
51 [:issues_by_tracker, :issues_by_version, :issues_by_category, :issues_by_assigned_to, 48 def test_get_issue_report_details
52 :issues_by_author, :issues_by_subproject].each do |ivar| 49 %w(tracker version priority category assigned_to author subproject).each do |detail|
53 should_assign_to ivar 50 get :issue_report_details, :id => 1, :detail => detail
54 should "set a value for #{ivar}" do 51
55 assert assigns[ivar.to_s].present? 52 assert_response :success
56 end 53 assert_template 'issue_report_details'
54 assert_not_nil assigns(:field)
55 assert_not_nil assigns(:rows)
56 assert_not_nil assigns(:data)
57 assert_not_nil assigns(:report_title)
57 end 58 end
58 end 59 end
59 60
60 context "GET :issue_report_details" do 61 def test_get_issue_report_details_by_priority
61 %w(tracker version priority category assigned_to author subproject).each do |detail| 62 get :issue_report_details, :id => 1, :detail => 'priority'
62 context "for #{detail}" do 63 assert_equal IssuePriority.all.reverse, assigns(:rows)
63 setup do
64 get :issue_report_details, :id => 1, :detail => detail
65 end
66
67 should_respond_with :success
68 should_render_template :issue_report_details
69 should_assign_to :field
70 should_assign_to :rows
71 should_assign_to :data
72 should_assign_to :report_title
73 end
74 end
75
76 context "with an invalid detail" do
77 setup do
78 get :issue_report_details, :id => 1, :detail => 'invalid'
79 end
80
81 should_respond_with :redirect
82 should_redirect_to('the issue report') {{:controller => 'reports', :action => 'issue_report', :id => 'ecookbook'}}
83 end
84
85 end 64 end
86 65
66 def test_get_issue_report_details_with_an_invalid_detail
67 get :issue_report_details, :id => 1, :detail => 'invalid'
68
69 assert_redirected_to '/projects/ecookbook/issues/report'
70 end
87 end 71 end