Move omniauth form partial to a component

This way we simplify the view a little bit and replace some slow system
tests with faster component tests.
This commit is contained in:
Javi Martín
2024-10-25 18:03:36 +02:00
parent 58639b64fa
commit 3931b43b87
8 changed files with 100 additions and 130 deletions

View File

@@ -0,0 +1,56 @@
require "rails_helper"
describe Devise::OmniauthFormComponent do
describe "#oauth_logins" do
let(:component) { Devise::OmniauthFormComponent.new("sign_up") }
before do
Setting["feature.facebook_login"] = false
Setting["feature.twitter_login"] = false
Setting["feature.google_login"] = false
Setting["feature.wordpress_login"] = false
end
it "is not rendered when all authentications are disabled" do
render_inline component
expect(page).not_to be_rendered
end
it "renders the twitter link when the feature is enabled" do
Setting["feature.twitter_login"] = true
render_inline component
expect(page).to have_link "Twitter"
expect(page).to have_link count: 1
end
it "renders the facebook link when the feature is enabled" do
Setting["feature.facebook_login"] = true
render_inline component
expect(page).to have_link "Facebook"
expect(page).to have_link count: 1
end
it "renders the google link when the feature is enabled" do
Setting["feature.google_login"] = true
render_inline component
expect(page).to have_link "Google"
expect(page).to have_link count: 1
end
it "renders the wordpress link when the feature is enabled" do
Setting["feature.wordpress_login"] = true
render_inline component
expect(page).to have_link "Wordpress"
expect(page).to have_link count: 1
end
end
end