- <%# if there are no SSO auths enabled, we don't ask the user if they have a password %>
- <% if authentication_enabled_providers.any? %>
+ <% if SiteConfig.allow_email_password_login %>
diff --git a/spec/fixtures/files/300x100.svg b/spec/fixtures/files/300x100.svg
new file mode 100644
index 000000000..e455796e5
--- /dev/null
+++ b/spec/fixtures/files/300x100.svg
@@ -0,0 +1,6 @@
+
diff --git a/spec/requests/editor_spec.rb b/spec/requests/editor_spec.rb
index f80e795f3..be4d5cd9f 100644
--- a/spec/requests/editor_spec.rb
+++ b/spec/requests/editor_spec.rb
@@ -7,6 +7,18 @@ RSpec.describe "Editor", type: :request do
get new_path
expect(response).to have_http_status(:ok)
+ end
+ end
+
+ context "when email login is allowed in /admin/config" do
+ before do
+ allow(SiteConfig).to receive(:allow_email_password_login).and_return(true)
+ end
+
+ it "asks the non logged in user to sign in, with email signin enabled" do
+ get new_path
+
+ expect(response.body).to include("Email")
expect(response.body).to include("Password")
end
end
diff --git a/spec/requests/registrations_spec.rb b/spec/requests/registrations_spec.rb
index 640c3717e..7a7026712 100644
--- a/spec/requests/registrations_spec.rb
+++ b/spec/requests/registrations_spec.rb
@@ -15,27 +15,36 @@ RSpec.describe "Registrations", type: :request do
end
end
- it "shows the sign in text for password based authentication" do
- get sign_up_path
-
- expect(response.body).to include("Have a password? Continue with your email address")
- end
-
- it "does not show the password based authentication hint if there are no single sign in options enabled" do
+ it "only shows the single sign on options if they are present" do
allow(Authentication::Providers).to receive(:enabled).and_return([])
get sign_up_path
expect(response.body).not_to include("Have a password? Continue with your email address")
end
+ end
- it "only shows the single sign on options if they are present" do
- allow(Authentication::Providers).to receive(:enabled).and_return([])
+ context "when email login is enabled in /admin/config" do
+ before do
+ allow(SiteConfig).to receive(:allow_email_password_login).and_return(true)
+ end
+ it "shows the sign in text for password based authentication" do
get sign_up_path
- expect(response.body).to include("Password")
- expect(response.body).not_to include("Continue with")
+ expect(response.body).to include("Have a password? Continue with your email address")
+ end
+ end
+
+ context "when email login is disabled in /admin/config" do
+ before do
+ allow(SiteConfig).to receive(:allow_email_password_login).and_return(false)
+ end
+
+ it "does not show the sign in text for password based authentication" do
+ get sign_up_path
+
+ expect(response.body).not_to include("Have a password? Continue with your email address")
end
end
diff --git a/spec/system/articles/user_edits_an_article_spec.rb b/spec/system/articles/user_edits_an_article_spec.rb
index 0b4fc8f01..2b9242a83 100644
--- a/spec/system/articles/user_edits_an_article_spec.rb
+++ b/spec/system/articles/user_edits_an_article_spec.rb
@@ -4,8 +4,15 @@ RSpec.describe "Editing with an editor", type: :system, js: true do
let(:template) { file_fixture("article_published.txt").read }
let(:user) { create(:user) }
let(:article) { create(:article, user: user, body_markdown: template) }
+ let(:svg_image) { file_fixture("300x100.svg").read }
before do
+ allow(SiteConfig).to receive(:main_social_image).and_return("https://dummyimage.com/800x600.jpg")
+ allow(SiteConfig).to receive(:logo_png).and_return("https://dummyimage.com/800x600.png")
+ allow(SiteConfig).to receive(:mascot_image_url).and_return("https://dummyimage.com/800x600.jpg")
+ allow(SiteConfig).to receive(:suggested_tags).and_return("coding, beginners")
+ allow(SiteConfig).to receive(:suggested_users).and_return("romagueramica")
+ allow(SiteConfig).to receive(:logo_svg).and_return(svg_image)
sign_in user
end
diff --git a/spec/system/user_logs_in_with_password_spec.rb b/spec/system/user_logs_in_with_password_spec.rb
index 88a7f8b95..19573cd41 100644
--- a/spec/system/user_logs_in_with_password_spec.rb
+++ b/spec/system/user_logs_in_with_password_spec.rb
@@ -11,6 +11,7 @@ RSpec.describe "Authenticating with a password" do
let!(:user) { create(:user, password: password, password_confirmation: password) }
before do
+ allow(SiteConfig).to receive(:allow_email_password_login).and_return(true)
visit sign_up_path
end