##// END OF EJS Templates
Test cleanup....
Jean-Philippe Lang -
r8342:13dca2fd3dd4
parent child
Show More
@@ -1,87 +1,64
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 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.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
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,
29 :roles,
24 :roles,
30 :member_roles,
25 :member_roles,
31 :members,
26 :members,
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
45 get :issue_report, :id => 1
35 get :issue_report, :id => 1
46 end
47
36
48 should_respond_with :success
37 assert_response :success
49 should_render_template :issue_report
38 assert_template 'issue_report'
50
39
51 [:issues_by_tracker, :issues_by_version, :issues_by_category, :issues_by_assigned_to,
40 [:issues_by_tracker, :issues_by_version, :issues_by_category, :issues_by_assigned_to,
52 :issues_by_author, :issues_by_subproject].each do |ivar|
41 :issues_by_author, :issues_by_subproject].each do |ivar|
53 should_assign_to ivar
42 assert_not_nil assigns(ivar)
54 should "set a value for #{ivar}" do
55 assert assigns[ivar.to_s].present?
56 end
57 end
43 end
58 end
44 end
59
45
60 context "GET :issue_report_details" do
46 def test_get_issue_report_details
61 %w(tracker version priority category assigned_to author subproject).each do |detail|
47 %w(tracker version priority category assigned_to author subproject).each do |detail|
62 context "for #{detail}" do
63 setup do
64 get :issue_report_details, :id => 1, :detail => detail
48 get :issue_report_details, :id => 1, :detail => detail
65 end
66
49
67 should_respond_with :success
50 assert_response :success
68 should_render_template :issue_report_details
51 assert_template 'issue_report_details'
69 should_assign_to :field
52 assert_not_nil assigns(:field)
70 should_assign_to :rows
53 assert_not_nil assigns(:rows)
71 should_assign_to :data
54 assert_not_nil assigns(:data)
72 should_assign_to :report_title
55 assert_not_nil assigns(:report_title)
73 end
56 end
74 end
57 end
75
58
76 context "with an invalid detail" do
59 def test_get_issue_report_details_with_an_invalid_detail
77 setup do
78 get :issue_report_details, :id => 1, :detail => 'invalid'
60 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
61
62 assert_redirected_to '/projects/ecookbook/issues/report'
85 end
63 end
86
87 end
64 end
General Comments 0
You need to be logged in to leave comments. Login now