##// END OF EJS Templates
remove trailing white-spaces from test/functional/users_controller_test.rb....
Toshi MARUYAMA -
r6508:0a369b73831d
parent child
Show More
@@ -5,12 +5,12
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 #
8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 #
13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -23,9 +23,9 class UsersController; def rescue_action(e) raise e end; end
23 23
24 24 class UsersControllerTest < ActionController::TestCase
25 25 include Redmine::I18n
26
26
27 27 fixtures :users, :projects, :members, :member_roles, :roles, :auth_sources, :custom_fields, :custom_values, :groups_users
28
28
29 29 def setup
30 30 @controller = UsersController.new
31 31 @request = ActionController::TestRequest.new
@@ -33,7 +33,7 class UsersControllerTest < ActionController::TestCase
33 33 User.current = nil
34 34 @request.session[:user_id] = 1 # admin
35 35 end
36
36
37 37 def test_index
38 38 get :index
39 39 assert_response :success
@@ -48,7 +48,7 class UsersControllerTest < ActionController::TestCase
48 48 # active users only
49 49 assert_nil assigns(:users).detect {|u| !u.active?}
50 50 end
51
51
52 52 def test_index_with_name_filter
53 53 get :index, :name => 'john'
54 54 assert_response :success
@@ -58,7 +58,7 class UsersControllerTest < ActionController::TestCase
58 58 assert_equal 1, users.size
59 59 assert_equal 'John', users.first.firstname
60 60 end
61
61
62 62 def test_index_with_group_filter
63 63 get :index, :group_id => '10'
64 64 assert_response :success
@@ -67,17 +67,17 class UsersControllerTest < ActionController::TestCase
67 67 assert users.any?
68 68 assert_equal([], (users - Group.find(10).users))
69 69 end
70
70
71 71 def test_show
72 72 @request.session[:user_id] = nil
73 73 get :show, :id => 2
74 74 assert_response :success
75 75 assert_template 'show'
76 76 assert_not_nil assigns(:user)
77
77
78 78 assert_tag 'li', :content => /Phone number/
79 79 end
80
80
81 81 def test_show_should_not_display_hidden_custom_fields
82 82 @request.session[:user_id] = nil
83 83 UserCustomField.find_by_name('Phone number').update_attribute :visible, false
@@ -85,7 +85,7 class UsersControllerTest < ActionController::TestCase
85 85 assert_response :success
86 86 assert_template 'show'
87 87 assert_not_nil assigns(:user)
88
88
89 89 assert_no_tag 'li', :content => /Phone number/
90 90 end
91 91
@@ -105,20 +105,20 class UsersControllerTest < ActionController::TestCase
105 105 get :show, :id => 5
106 106 assert_response 404
107 107 end
108
108
109 109 def test_show_should_not_reveal_users_with_no_visible_activity_or_project
110 110 @request.session[:user_id] = nil
111 111 get :show, :id => 9
112 112 assert_response 404
113 113 end
114
114
115 115 def test_show_inactive_by_admin
116 116 @request.session[:user_id] = 1
117 117 get :show, :id => 5
118 118 assert_response 200
119 119 assert_not_nil assigns(:user)
120 120 end
121
121
122 122 def test_show_displays_memberships_based_on_project_visibility
123 123 @request.session[:user_id] = 1
124 124 get :show, :id => 2
@@ -128,13 +128,13 class UsersControllerTest < ActionController::TestCase
128 128 project_ids = memberships.map(&:project_id)
129 129 assert project_ids.include?(2) #private project admin can see
130 130 end
131
131
132 132 def test_show_current_should_require_authentication
133 133 @request.session[:user_id] = nil
134 134 get :show, :id => 'current'
135 135 assert_response 302
136 136 end
137
137
138 138 def test_show_current
139 139 @request.session[:user_id] = 2
140 140 get :show, :id => 'current'
@@ -142,18 +142,18 class UsersControllerTest < ActionController::TestCase
142 142 assert_template 'show'
143 143 assert_equal User.find(2), assigns(:user)
144 144 end
145
145
146 146 def test_new
147 147 get :new
148
148
149 149 assert_response :success
150 150 assert_template :new
151 151 assert assigns(:user)
152 152 end
153
153
154 154 def test_create
155 155 Setting.bcc_recipients = '1'
156
156
157 157 assert_difference 'User.count' do
158 158 assert_difference 'ActionMailer::Base.deliveries.size' do
159 159 post :create,
@@ -169,35 +169,35 class UsersControllerTest < ActionController::TestCase
169 169 :send_information => '1'
170 170 end
171 171 end
172
172
173 173 user = User.first(:order => 'id DESC')
174 174 assert_redirected_to :controller => 'users', :action => 'edit', :id => user.id
175
175
176 176 assert_equal 'John', user.firstname
177 177 assert_equal 'Doe', user.lastname
178 178 assert_equal 'jdoe', user.login
179 179 assert_equal 'jdoe@gmail.com', user.mail
180 180 assert_equal 'none', user.mail_notification
181 181 assert user.check_password?('secret')
182
182
183 183 mail = ActionMailer::Base.deliveries.last
184 184 assert_not_nil mail
185 185 assert_equal [user.mail], mail.bcc
186 186 assert mail.body.include?('secret')
187 187 end
188
188
189 189 def test_create_with_failure
190 190 assert_no_difference 'User.count' do
191 191 post :create, :user => {}
192 192 end
193
193
194 194 assert_response :success
195 195 assert_template 'new'
196 196 end
197 197
198 198 def test_edit
199 199 get :edit, :id => 2
200
200
201 201 assert_response :success
202 202 assert_template 'edit'
203 203 assert_equal User.find(2), assigns(:user)
@@ -219,18 +219,18 class UsersControllerTest < ActionController::TestCase
219 219 assert_no_difference 'User.count' do
220 220 put :update, :id => 2, :user => {:firstname => ''}
221 221 end
222
222
223 223 assert_response :success
224 224 assert_template 'edit'
225 225 end
226
226
227 227 def test_update_with_group_ids_should_assign_groups
228 228 put :update, :id => 2, :user => {:group_ids => ['10']}
229
229
230 230 user = User.find(2)
231 231 assert_equal [10], user.group_ids
232 232 end
233
233
234 234 def test_update_with_activation_should_send_a_notification
235 235 u = User.new(:firstname => 'Foo', :lastname => 'Bar', :mail => 'foo.bar@somenet.foo', :language => 'fr')
236 236 u.login = 'foo'
@@ -238,7 +238,7 class UsersControllerTest < ActionController::TestCase
238 238 u.save!
239 239 ActionMailer::Base.deliveries.clear
240 240 Setting.bcc_recipients = '1'
241
241
242 242 put :update, :id => u.id, :user => {:status => User::STATUS_ACTIVE}
243 243 assert u.reload.active?
244 244 mail = ActionMailer::Base.deliveries.last
@@ -246,15 +246,15 class UsersControllerTest < ActionController::TestCase
246 246 assert_equal ['foo.bar@somenet.foo'], mail.bcc
247 247 assert mail.body.include?(ll('fr', :notice_account_activated))
248 248 end
249
249
250 250 def test_update_with_password_change_should_send_a_notification
251 251 ActionMailer::Base.deliveries.clear
252 252 Setting.bcc_recipients = '1'
253
253
254 254 put :update, :id => 2, :user => {:password => 'newpass', :password_confirmation => 'newpass'}, :send_information => '1'
255 255 u = User.find(2)
256 256 assert u.check_password?('newpass')
257
257
258 258 mail = ActionMailer::Base.deliveries.last
259 259 assert_not_nil mail
260 260 assert_equal [u.mail], mail.bcc
@@ -272,7 +272,7 class UsersControllerTest < ActionController::TestCase
272 272 assert_equal nil, u.reload.auth_source
273 273 assert u.check_password?('newpass')
274 274 end
275
275
276 276 def test_destroy
277 277 assert_difference 'User.count', -1 do
278 278 delete :destroy, :id => 2
@@ -290,20 +290,20 class UsersControllerTest < ActionController::TestCase
290 290
291 291 def test_destroy_should_be_denied_for_non_admin_users
292 292 @request.session[:user_id] = 3
293
293
294 294 assert_no_difference 'User.count' do
295 295 get :destroy, :id => 2
296 296 end
297 297 assert_response 403
298 298 end
299
299
300 300 def test_edit_membership
301 301 post :edit_membership, :id => 2, :membership_id => 1,
302 302 :membership => { :role_ids => [2]}
303 303 assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships'
304 304 assert_equal [2], Member.find(1).role_ids
305 305 end
306
306
307 307 def test_destroy_membership
308 308 post :destroy_membership, :id => 2, :membership_id => 1
309 309 assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships'
General Comments 0
You need to be logged in to leave comments. Login now