Merge pull request #2142 from basecamp/validate-name-length

Limit length of full name during signup
This commit is contained in:
Kevin McConnell
2025-12-15 11:08:43 +00:00
committed by GitHub
3 changed files with 15 additions and 1 deletions
+1
View File
@@ -8,6 +8,7 @@ class Signup
validates :email_address, format: { with: URI::MailTo::EMAIL_REGEXP }, on: :identity_creation
validates :full_name, :identity, presence: true, on: :completion
validates :full_name, length: { maximum: 240 }
def initialize(...)
super
+1 -1
View File
@@ -4,7 +4,7 @@
<h1 class="txt-x-large font-weight-black margin-block-end"><%= @page_title %></h1>
<%= form_with model: @signup, url: signup_completion_path, scope: "signup", class: "flex flex-column gap", data: { controller: "form" } do |form| %>
<%= form.text_field :full_name, class: "input txt-large", autocomplete: "name", placeholder: "Enter your full name…", autofocus: true, required: true %>
<%= form.text_field :full_name, class: "input txt-large", autocomplete: "name", placeholder: "Enter your full name…", autofocus: true, required: true, maxlength: 240 %>
<p>You're one step away. Just enter your name to get your own Fizzy account.</p>
+13
View File
@@ -72,4 +72,17 @@ class SignupTest < ActiveSupport::TestCase
assert_nil signup.user
end
end
test "#complete with name that is too long" do
Current.without_account do
signup = Signup.new(full_name: "A" * 241, identity: identities(:kevin))
signup.expects(:create_tenant).never
assert_not signup.complete
assert signup.errors[:full_name].any?
assert_nil signup.account
assert_nil signup.user
end
end
end