Show Wordpress login button if it's the only one enabled

This commit is contained in:
Julian Herrero
2020-07-25 11:21:41 +07:00
committed by Javi Martín
parent b1c2a4a9f2
commit b7b05b55fe
2 changed files with 98 additions and 1 deletions

View File

@@ -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" }} }