A platform for community discussion. Free, open, simple.
FIX: Name field should appear in the signup form for login-required sites (#30634)
Osama Sayegh4f9359d05663
diff --git a/app/models/site.rb b/app/models/site.rbindex e5e08a3ffc2..314da2ba3cc 100644--- a/app/models/site.rb+++ b/app/models/site.rb@@ -214,6 +214,8 @@ class SiteDiscourse.enabled_auth_providers.map do |provider|AuthProviderSerializer.new(provider, root: false, scope: guardian)end,+ full_name_required_for_signup:,+ full_name_visible_in_signup:,}.to_json)end@@ -252,4 +254,12 @@ class Site# the cache is validated based on the sequenceMessageBus.publish(SITE_JSON_CHANNEL, "")end++ def self.full_name_required_for_signup+ SiteSetting.enable_names && SiteSetting.full_name_requirement == "required_at_signup"+ end++ def self.full_name_visible_in_signup+ SiteSetting.enable_names && SiteSetting.full_name_requirement != "hidden_at_signup"+ endenddiff --git a/app/serializers/site_serializer.rb b/app/serializers/site_serializer.rbindex d145dcf001e..c39133b4233 100644--- a/app/serializers/site_serializer.rb+++ b/app/serializers/site_serializer.rb@@ -384,11 +384,11 @@ class SiteSerializer < ApplicationSerializerenddef full_name_required_for_signup- SiteSetting.enable_names && SiteSetting.full_name_requirement == "required_at_signup"+ Site.full_name_required_for_signupenddef full_name_visible_in_signup- SiteSetting.enable_names && SiteSetting.full_name_requirement != "hidden_at_signup"+ Site.full_name_visible_in_signupendprivatediff --git a/spec/system/page_objects/modals/signup.rb b/spec/system/page_objects/modals/signup.rbindex bd4256d0c25..0e8e7e0ccd7 100644--- a/spec/system/page_objects/modals/signup.rb+++ b/spec/system/page_objects/modals/signup.rb@@ -43,6 +43,14 @@ module PageObjectshas_no_css?("#new-account-password")end+ def has_name_input?+ has_css?("#new-account-name")+ end++ def has_no_name_input?+ has_no_css?("#new-account-name")+ end+def fill_input(selector, text)if page.has_css?("html.mobile-view", wait: 0)expect(page).to have_css(".d-modal:not(.is-animating)")diff --git a/spec/system/page_objects/pages/signup.rb b/spec/system/page_objects/pages/signup.rbindex b807faa82a0..5243b126271 100644--- a/spec/system/page_objects/pages/signup.rb+++ b/spec/system/page_objects/pages/signup.rb@@ -43,6 +43,14 @@ module PageObjectshas_no_css?("#new-account-password")end+ def has_name_input?+ has_css?("#new-account-name")+ end++ def has_no_name_input?+ has_no_css?("#new-account-name")+ end+def fill_input(selector, text)if page.has_css?("html.mobile-view", wait: 0)expect(page).to have_no_css(".d-modal.is-animating")diff --git a/spec/system/signup_spec.rb b/spec/system/signup_spec.rbindex 389a1a6967f..e042bd61fa0 100644--- a/spec/system/signup_spec.rb+++ b/spec/system/signup_spec.rb@@ -296,6 +296,57 @@ shared_examples "signup scenarios" do |signup_page_object, login_page_object|expect(page).to have_css(".invited-by .user-info[data-username='#{inviter.username}']")end++ describe "full name field" do+ context "when full_name_requirement is optional_at_signup" do+ before { SiteSetting.full_name_requirement = "optional_at_signup" }++ context "when login_required is true" do+ before { SiteSetting.login_required = true }++ it "displays the name field" do+ signup_form.open+ expect(signup_form).to have_name_input+ end+ end++ context "when enable_names is false" do+ before { SiteSetting.enable_names = false }++ it "hides the name field" do+ signup_form.open+ expect(signup_form).to have_no_name_input+ end+ end+ end++ context "when full_name_requirement is hidden_at_signup" do+ before { SiteSetting.full_name_requirement = "hidden_at_signup" }++ it "hides the name field" do+ signup_form.open+ expect(signup_form).to have_no_name_input+ end+ end++ context "when full_name_requirement is required_at_signup" do+ before { SiteSetting.full_name_requirement = "required_at_signup" }++ it "displays the name field" do+ signup_form.open+ expect(signup_form).to have_name_input+ end++ context "when enable_names is false" do+ before { SiteSetting.enable_names = false }++ it "hides the name field" do+ signup_form.open+ expect(signup_form).to have_no_name_input+ end+ end+ end+ endenddescribe "Signup", type: :system do