mirror of
https://github.com/heartcombo/devise.git
synced 2026-04-28 03:00:29 -04:00
Properly handle failure.
This commit is contained in:
@@ -87,55 +87,21 @@ class OmniauthableIntegrationTest < ActionController::IntegrationTest
|
||||
assert !session["devise.facebook_data"]
|
||||
end
|
||||
|
||||
# test "[FAILURE] shows 404 if no code or error are given as params" do
|
||||
# assert_raise AbstractController::ActionNotFound do
|
||||
# visit "/users/oauth/facebook/callback"
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# test "[FAILURE] raises an error if model does not implement a hook" do
|
||||
# begin
|
||||
# visit "/users/oauth/github/callback?code=123456"
|
||||
# raise "Expected visit to raise an error"
|
||||
# rescue Exception => e
|
||||
# assert_match "User does not respond to find_for_github_oauth", e.message
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# test "[FAILURE] handles callback error parameter according to the specification" do
|
||||
# visit "/users/oauth/facebook/callback?error=access_denied"
|
||||
# assert_current_url "/users/sign_in"
|
||||
# assert_contain 'Could not authorize you from Facebook because "Access denied".'
|
||||
# end
|
||||
#
|
||||
# test "[FAILURE] handles callback error_reason just for Facebook compatibility" do
|
||||
# visit "/users/oauth/facebook/callback?error_reason=access_denied"
|
||||
# assert_current_url "/users/sign_in"
|
||||
# assert_contain 'Could not authorize you from Facebook because "Access denied".'
|
||||
# end
|
||||
#
|
||||
# test "[FAILURE][I18N] uses I18n for custom messages" do
|
||||
# visit "/users/oauth/facebook/callback?error=access_denied"
|
||||
# assert_current_url "/users/sign_in"
|
||||
# assert_contain 'Could not authorize you from Facebook because "Access denied"'
|
||||
# end
|
||||
#
|
||||
# test "[FAILURE][I18N] uses I18n with oauth callback scope for custom messages" do
|
||||
# store_translations :en, :devise => { :oauth_callbacks => {
|
||||
# :facebook => { :failure => "Access denied bro" } } } do
|
||||
# visit "/users/oauth/facebook/callback?error=access_denied"
|
||||
# assert_current_url "/users/sign_in"
|
||||
# assert_contain "Access denied bro"
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# test "[FAILURE][I18N] uses I18n with oauth callback scope and resource name for custom messages" do
|
||||
# store_translations :en, :devise => { :oauth_callbacks => {
|
||||
# :user => { :facebook => { :failure => "Access denied user" } },
|
||||
# :facebook => { :failure => "Access denied bro" } } } do
|
||||
# visit "/users/oauth/facebook/callback?error=access_denied"
|
||||
# assert_current_url "/users/sign_in"
|
||||
# assert_contain "Access denied user"
|
||||
# end
|
||||
# end
|
||||
test "handles callback error parameter according to the specification" do
|
||||
visit "/users/auth/facebook/callback?error=access_denied"
|
||||
assert_current_url "/users/sign_in"
|
||||
assert_contain 'Could not authorize you from Facebook because "Access denied".'
|
||||
end
|
||||
|
||||
test "handles other exceptions from omniauth" do
|
||||
Devise::OmniAuth.stub!(:facebook) do |b|
|
||||
b.post('/oauth/access_token') { [401, {}, {}.to_json] }
|
||||
end
|
||||
|
||||
visit "/users/sign_in"
|
||||
click_link "Sign in with facebook"
|
||||
|
||||
assert_current_url "/users/sign_in"
|
||||
assert_contain 'Could not authorize you from Facebook because "Invalid credentials".'
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user