diff --git a/app/views/devise/_omniauth_form.html.erb b/app/views/devise/_omniauth_form.html.erb index 516e32cbb..8cbe25844 100644 --- a/app/views/devise/_omniauth_form.html.erb +++ b/app/views/devise/_omniauth_form.html.erb @@ -1,4 +1,4 @@ -<% if feature?(:twitter_login) || feature?(:facebook_login) || feature?(:google_login) %> +<% if oauth_logins.any? %>
diff --git a/spec/system/users_auth_spec.rb b/spec/system/users_auth_spec.rb index 4b38b80ec..63663ca7c 100644 --- a/spec/system/users_auth_spec.rb +++ b/spec/system/users_auth_spec.rb @@ -100,6 +100,103 @@ describe "Users" do end context "OAuth authentication" do + context "Form buttons" do + before do + Setting["feature.facebook_login"] = false + Setting["feature.twitter_login"] = false + Setting["feature.google_login"] = false + Setting["feature.wordpress_login"] = false + end + + scenario "No button will appear if all features are disabled" do + visit new_user_registration_path + + expect(page).not_to have_link "Twitter" + expect(page).not_to have_link "Facebook" + expect(page).not_to have_link "Google" + expect(page).not_to have_link "Wordpress" + + visit new_user_session_path + + expect(page).not_to have_link "Twitter" + expect(page).not_to have_link "Facebook" + expect(page).not_to have_link "Google" + expect(page).not_to have_link "Wordpress" + end + + scenario "Twitter login button will appear if feature is enabled" do + Setting["feature.twitter_login"] = true + + visit new_user_registration_path + + expect(page).to have_link "Twitter" + expect(page).not_to have_link "Facebook" + expect(page).not_to have_link "Google" + expect(page).not_to have_link "Wordpress" + + visit new_user_session_path + + expect(page).to have_link "Twitter" + expect(page).not_to have_link "Facebook" + expect(page).not_to have_link "Google" + expect(page).not_to have_link "Wordpress" + end + + scenario "Facebook login button will appear if feature is enabled" do + Setting["feature.facebook_login"] = true + + visit new_user_registration_path + + expect(page).not_to have_link "Twitter" + expect(page).to have_link "Facebook" + expect(page).not_to have_link "Google" + expect(page).not_to have_link "Wordpress" + + visit new_user_session_path + + expect(page).not_to have_link "Twitter" + expect(page).to have_link "Facebook" + expect(page).not_to have_link "Google" + expect(page).not_to have_link "Wordpress" + end + + scenario "Google login button will appear if feature is enabled" do + Setting["feature.google_login"] = true + + visit new_user_registration_path + + expect(page).not_to have_link "Twitter" + expect(page).not_to have_link "Facebook" + expect(page).to have_link "Google" + expect(page).not_to have_link "Wordpress" + + visit new_user_session_path + + expect(page).not_to have_link "Twitter" + expect(page).not_to have_link "Facebook" + expect(page).to have_link "Google" + expect(page).not_to have_link "Wordpress" + end + + scenario "Wordpress login button will appear if feature is enabled" do + Setting["feature.wordpress_login"] = true + + visit new_user_registration_path + + expect(page).not_to have_link "Twitter" + expect(page).not_to have_link "Facebook" + expect(page).not_to have_link "Google" + expect(page).to have_link "Wordpress" + + visit new_user_session_path + + expect(page).not_to have_link "Twitter" + expect(page).not_to have_link "Facebook" + expect(page).not_to have_link "Google" + expect(page).to have_link "Wordpress" + end + end + context "Twitter" do let(:twitter_hash) { { provider: "twitter", uid: "12345", info: { name: "manuela" }} } let(:twitter_hash_with_email) { { provider: "twitter", uid: "12345", info: { name: "manuela", email: "manuelacarmena@example.com" }} }