| 1227 |
1227 |
assert User.find_by_id(9).active?
|
| 1228 |
1228 |
end
|
| 1229 |
1229 |
|
|
1230 |
def test_bulk_lock_should_destroy_autologin_and_session_tokens
|
|
1231 |
autologin_token = Token.create!(:user_id => 2, :action => 'autologin')
|
|
1232 |
session_token = Token.create!(:user_id => 2, :action => 'session')
|
|
1233 |
|
|
1234 |
post :bulk_lock, :params => {:ids => [2]}
|
|
1235 |
assert_nil Token.find_by_id(autologin_token.id)
|
|
1236 |
assert_nil Token.find_by_id(session_token.id)
|
|
1237 |
end
|
|
1238 |
|
|
1239 |
def test_bulk_lock_should_send_security_notification_for_admins
|
|
1240 |
user = User.find(2)
|
|
1241 |
user.admin = true
|
|
1242 |
user.save!
|
|
1243 |
|
|
1244 |
ActionMailer::Base.deliveries.clear
|
|
1245 |
post :bulk_lock, :params => {:ids => [2]}
|
|
1246 |
|
|
1247 |
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
|
1248 |
assert_mail_body_match(
|
|
1249 |
I18n.t(
|
|
1250 |
:mail_body_security_notification_remove,
|
|
1251 |
field: I18n.t(:field_admin),
|
|
1252 |
value: 'jsmith'
|
|
1253 |
),
|
|
1254 |
mail
|
|
1255 |
)
|
|
1256 |
end
|
|
1257 |
|
|
1258 |
def test_bulk_unlock_should_send_security_notification_for_admins
|
|
1259 |
user = User.find(2)
|
|
1260 |
user.admin = true
|
|
1261 |
user.status = User::STATUS_LOCKED
|
|
1262 |
user.save!
|
|
1263 |
|
|
1264 |
ActionMailer::Base.deliveries.clear
|
|
1265 |
post :bulk_unlock, :params => {:ids => [2]}
|
|
1266 |
|
|
1267 |
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
|
1268 |
assert_mail_body_match(
|
|
1269 |
I18n.t(
|
|
1270 |
:mail_body_security_notification_add,
|
|
1271 |
field: I18n.t(:field_admin),
|
|
1272 |
value: 'jsmith'
|
|
1273 |
),
|
|
1274 |
mail
|
|
1275 |
)
|
|
1276 |
end
|
|
1277 |
|
| 1230 |
1278 |
def test_bulk_lock_should_not_lock_current_user
|
| 1231 |
1279 |
assert_difference 'User.status(User::STATUS_LOCKED).count', 1 do
|
| 1232 |
1280 |
delete :bulk_lock, :params => {:ids => [2, 1]}
|