##// END OF EJS Templates
use escaped "Can't" constant at IssueStatusesControllerTest...
Toshi MARUYAMA -
r12530:760f88bd58ca
parent child
Show More
@@ -1,150 +1,150
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
2 # Copyright (C) 2006-2014 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
19
20 class ActivitiesControllerTest < ActionController::TestCase
20 class ActivitiesControllerTest < ActionController::TestCase
21 fixtures :projects, :trackers, :issue_statuses, :issues,
21 fixtures :projects, :trackers, :issue_statuses, :issues,
22 :enumerations, :users, :issue_categories,
22 :enumerations, :users, :issue_categories,
23 :projects_trackers,
23 :projects_trackers,
24 :roles,
24 :roles,
25 :member_roles,
25 :member_roles,
26 :members,
26 :members,
27 :groups_users,
27 :groups_users,
28 :enabled_modules,
28 :enabled_modules,
29 :journals, :journal_details
29 :journals, :journal_details
30
30
31
31
32 def test_project_index
32 def test_project_index
33 get :index, :id => 1, :with_subprojects => 0
33 get :index, :id => 1, :with_subprojects => 0
34 assert_response :success
34 assert_response :success
35 assert_template 'index'
35 assert_template 'index'
36 assert_not_nil assigns(:events_by_day)
36 assert_not_nil assigns(:events_by_day)
37
37
38 assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
38 assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
39 assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
39 assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
40 end
40 end
41
41
42 def test_project_index_with_invalid_project_id_should_respond_404
42 def test_project_index_with_invalid_project_id_should_respond_404
43 get :index, :id => 299
43 get :index, :id => 299
44 assert_response 404
44 assert_response 404
45 end
45 end
46
46
47 def test_previous_project_index
47 def test_previous_project_index
48 get :index, :id => 1, :from => 2.days.ago.to_date
48 get :index, :id => 1, :from => 2.days.ago.to_date
49 assert_response :success
49 assert_response :success
50 assert_template 'index'
50 assert_template 'index'
51 assert_not_nil assigns(:events_by_day)
51 assert_not_nil assigns(:events_by_day)
52
52
53 assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
53 assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
54 assert_select 'dl dt.issue a', :text => /Can&#x27;t print recipes/
54 assert_select 'dl dt.issue a', :text => /#{ESCAPED_UCANT} print recipes/
55 end
55 end
56
56
57 def test_global_index
57 def test_global_index
58 @request.session[:user_id] = 1
58 @request.session[:user_id] = 1
59 get :index
59 get :index
60 assert_response :success
60 assert_response :success
61 assert_template 'index'
61 assert_template 'index'
62 assert_not_nil assigns(:events_by_day)
62 assert_not_nil assigns(:events_by_day)
63
63
64 i5 = Issue.find(5)
64 i5 = Issue.find(5)
65 d5 = User.find(1).time_to_date(i5.created_on)
65 d5 = User.find(1).time_to_date(i5.created_on)
66
66
67 assert_select 'h3', :text => /#{d5.day}/
67 assert_select 'h3', :text => /#{d5.day}/
68 assert_select 'dl dt.issue a', :text => /Subproject issue/
68 assert_select 'dl dt.issue a', :text => /Subproject issue/
69 end
69 end
70
70
71 def test_user_index
71 def test_user_index
72 @request.session[:user_id] = 1
72 @request.session[:user_id] = 1
73 get :index, :user_id => 2
73 get :index, :user_id => 2
74 assert_response :success
74 assert_response :success
75 assert_template 'index'
75 assert_template 'index'
76 assert_not_nil assigns(:events_by_day)
76 assert_not_nil assigns(:events_by_day)
77
77
78 assert_select 'h2 a[href=/users/2]', :text => 'John Smith'
78 assert_select 'h2 a[href=/users/2]', :text => 'John Smith'
79
79
80 i1 = Issue.find(1)
80 i1 = Issue.find(1)
81 d1 = User.find(1).time_to_date(i1.created_on)
81 d1 = User.find(1).time_to_date(i1.created_on)
82
82
83 assert_select 'h3', :text => /#{d1.day}/
83 assert_select 'h3', :text => /#{d1.day}/
84 assert_select 'dl dt.issue a', :text => /Can&#x27;t print recipes/
84 assert_select 'dl dt.issue a', :text => /#{ESCAPED_UCANT} print recipes/
85 end
85 end
86
86
87 def test_user_index_with_invalid_user_id_should_respond_404
87 def test_user_index_with_invalid_user_id_should_respond_404
88 get :index, :user_id => 299
88 get :index, :user_id => 299
89 assert_response 404
89 assert_response 404
90 end
90 end
91
91
92 def test_index_atom_feed
92 def test_index_atom_feed
93 get :index, :format => 'atom', :with_subprojects => 0
93 get :index, :format => 'atom', :with_subprojects => 0
94 assert_response :success
94 assert_response :success
95 assert_template 'common/feed'
95 assert_template 'common/feed'
96
96
97 assert_select 'feed' do
97 assert_select 'feed' do
98 assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0'
98 assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0'
99 assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?with_subprojects=0'
99 assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?with_subprojects=0'
100 assert_select 'entry' do
100 assert_select 'entry' do
101 assert_select 'link[href=?]', 'http://test.host/issues/11'
101 assert_select 'link[href=?]', 'http://test.host/issues/11'
102 end
102 end
103 end
103 end
104 end
104 end
105
105
106 def test_index_atom_feed_with_explicit_selection
106 def test_index_atom_feed_with_explicit_selection
107 get :index, :format => 'atom', :with_subprojects => 0,
107 get :index, :format => 'atom', :with_subprojects => 0,
108 :show_changesets => 1,
108 :show_changesets => 1,
109 :show_documents => 1,
109 :show_documents => 1,
110 :show_files => 1,
110 :show_files => 1,
111 :show_issues => 1,
111 :show_issues => 1,
112 :show_messages => 1,
112 :show_messages => 1,
113 :show_news => 1,
113 :show_news => 1,
114 :show_time_entries => 1,
114 :show_time_entries => 1,
115 :show_wiki_edits => 1
115 :show_wiki_edits => 1
116
116
117 assert_response :success
117 assert_response :success
118 assert_template 'common/feed'
118 assert_template 'common/feed'
119
119
120 assert_select 'feed' do
120 assert_select 'feed' do
121 assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'
121 assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'
122 assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'
122 assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'
123 assert_select 'entry' do
123 assert_select 'entry' do
124 assert_select 'link[href=?]', 'http://test.host/issues/11'
124 assert_select 'link[href=?]', 'http://test.host/issues/11'
125 end
125 end
126 end
126 end
127 end
127 end
128
128
129 def test_index_atom_feed_with_one_item_type
129 def test_index_atom_feed_with_one_item_type
130 get :index, :format => 'atom', :show_issues => '1'
130 get :index, :format => 'atom', :show_issues => '1'
131 assert_response :success
131 assert_response :success
132 assert_template 'common/feed'
132 assert_template 'common/feed'
133
133
134 assert_select 'title', :text => /Issues/
134 assert_select 'title', :text => /Issues/
135 end
135 end
136
136
137 def test_index_should_show_private_notes_with_permission_only
137 def test_index_should_show_private_notes_with_permission_only
138 journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes with searchkeyword', :private_notes => true)
138 journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes with searchkeyword', :private_notes => true)
139 @request.session[:user_id] = 2
139 @request.session[:user_id] = 2
140
140
141 get :index
141 get :index
142 assert_response :success
142 assert_response :success
143 assert_include journal, assigns(:events_by_day).values.flatten
143 assert_include journal, assigns(:events_by_day).values.flatten
144
144
145 Role.find(1).remove_permission! :view_private_notes
145 Role.find(1).remove_permission! :view_private_notes
146 get :index
146 get :index
147 assert_response :success
147 assert_response :success
148 assert_not_include journal, assigns(:events_by_day).values.flatten
148 assert_not_include journal, assigns(:events_by_day).values.flatten
149 end
149 end
150 end
150 end
General Comments 0
You need to be logged in to leave comments. Login now