-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only record event if account unlocking was successful
The implementation of `Users::UnlockingsController#update` was carried over from `UsersController#unlock` and I thought the order of the method calls was a bit odd. I've now added a controller test to highlight the problem and fixed it by reordering the method calls in the action.
- Loading branch information
1 parent
3b82f06
commit a15ae9c
Showing
2 changed files
with
11 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,16 @@ class Users::UnlockingsControllerTest < ActionController::TestCase | |
put :update, params: { user_id: user } | ||
end | ||
|
||
should "not record manual account unlock event if User#unlock! raises an exception" do | ||
user = build(:locked_user, id: 123) | ||
User.stubs(:find).returns(user) | ||
user.stubs(:unlock_access!).raises("boom!") | ||
|
||
EventLog.expects(:record_event).never | ||
|
||
assert_raises { put :update, params: { user_id: user } } | ||
end | ||
|
||
should "redirect to edit user page and display success notice" do | ||
user = create(:locked_user, email: "[email protected]") | ||
|
||
|