mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-09 14:58:05 -05:00
Use button_to to generate a POST form, disable turbo with OmniAuth
This changes the OmniAuth "sign in" links to use buttons, which can be wrapped in an actual HTML form with a method POST, making them work better with and without Turbo in the app. It doesn't require rails/ujs anymore in case of a non-Turbo app, as it previously did with links + method=POST. Turbo is disabled for those OmniAuth buttons, as they simply don't work trying to follow the redirect to the OmniAuth provider via fetch, causing CORS issues/errors.
This commit is contained in:
@@ -128,13 +128,17 @@ class OmniauthableIntegrationTest < Devise::IntegrationTest
|
||||
|
||||
test "generates a link to authenticate with provider" do
|
||||
visit "/users/sign_in"
|
||||
assert_select "a[href=?][data-method='post']", "/users/auth/facebook", text: "Sign in with FaceBook"
|
||||
assert_select "form[action=?][method=post]", "/users/auth/facebook" do
|
||||
assert_select "input[type=submit][value=?]", "Sign in with FaceBook"
|
||||
end
|
||||
end
|
||||
|
||||
test "generates a proper link when SCRIPT_NAME is set" do
|
||||
header 'SCRIPT_NAME', '/q'
|
||||
visit "/users/sign_in"
|
||||
assert_select "a[href=?][data-method='post']", "/q/users/auth/facebook", text: "Sign in with FaceBook"
|
||||
assert_select "form[action=?][method=post]", "/q/users/auth/facebook" do
|
||||
assert_select "input[type=submit][value=?]", "Sign in with FaceBook"
|
||||
end
|
||||
end
|
||||
|
||||
test "handles callback error parameter according to the specification" do
|
||||
|
||||
@@ -109,7 +109,7 @@ class SessionTimeoutTest < Devise::IntegrationTest
|
||||
follow_redirect!
|
||||
|
||||
assert_response :success
|
||||
assert_contain 'Sign in'
|
||||
assert_contain 'Log in'
|
||||
refute warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user