Limit length of full name during signup
If we don't validate for length, then signups that overflow the database columns will unnecessarily create and cancel a tenant. Adding a validation means we can avoid this.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user