Created
August 7, 2013 14:35
-
-
Save dbarrionuevo/6174611 to your computer and use it in GitHub Desktop.
Workflow to ensure correct catch of Omniauth login failure. Specs included.
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
OmniAuth.config.on_failure = Proc.new { |env| | |
OmniAuth::FailureEndpoint.new(env).redirect_to_failure | |
} |
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
get 'auth/failure', to: 'sessions#failure' |
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
def failure | |
redirect_to root_path, aler: "There was an error while authenticating" | |
end |
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
feature "Sign in with Facebook" do | |
context "with invalid data" do | |
scenario "doesn't create an user" do | |
OmniAuth.config.mock_auth[:facebook] = fb_invalid_data | |
visit root_path | |
click_on "Connect" | |
expect(User.count).to be_zero | |
end | |
scenario "redirects if a failure is found" do | |
OmniAuth.config.mock_auth[:facebook] = :invalid_credentials | |
visit root_path | |
click_on "Connect" | |
expect(current_path).to eql root_path | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment