forked from publiclab/plots2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: messages when logging in without password for oauth (publiclab#7292
- Loading branch information
1 parent
4d7086b
commit 6112ae0
Showing
2 changed files
with
14 additions
and
3 deletions.
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 |
---|---|---|
|
@@ -18,7 +18,7 @@ class UserSessionsControllerTest < ActionController::TestCase | |
assert_redirected_to '/dashboard' | ||
end | ||
|
||
test 'should login and redirect to corresct url' do | ||
test 'should login and redirect to correct url' do | ||
session[:return_to] = '/post?tags=question:question&template=question' | ||
post :create, params: { user_session: { username: users(:jeff).username, password: 'secretive' } } | ||
assert_redirected_to '/post?tags=question:question&template=question' | ||
|
@@ -303,7 +303,7 @@ class UserSessionsControllerTest < ActionController::TestCase | |
assert @response.redirect_url.include? "/notes/liked" | ||
end | ||
|
||
test "logging in through omniauth and then through normal login should display error and redirect" do | ||
test "logging in through omniauth and then logging in with username should display correct error and redirect" do | ||
request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:github1] | ||
# login through omniauth | ||
post :create | ||
|
@@ -314,6 +314,17 @@ class UserSessionsControllerTest < ActionController::TestCase | |
assert_equal flash[:error], "This account doesn't have a password set. It may be logged in with Github account, or you can set a new password via Forget password feature" | ||
end | ||
|
||
test "logging in through omniauth and then logging in with email should display correct error and redirect" do | ||
request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:github1] | ||
# login through omniauth | ||
post :create | ||
# logout | ||
post :destroy | ||
request.env['omniauth.auth'] = nil | ||
post :create, params: { user_session: { username: "[email protected]", password: "random"} } | ||
assert_equal flash[:error], "This account doesn't have a password set. It may be logged in with Github account, or you can set a new password via Forget password feature" | ||
end | ||
|
||
test "logging in with banned user through normal login should fail" do | ||
user = users(:bob) | ||
user.ban | ||
|