diff --git a/app/models/account_request.rb b/app/models/account_request.rb index 6845565671..a704cddcdb 100644 --- a/app/models/account_request.rb +++ b/app/models/account_request.rb @@ -21,6 +21,7 @@ class AccountRequest < ApplicationRecord validates :email, presence: true, uniqueness: true validates :request_details, presence: true, length: { minimum: 50 } validates :email, format: { with: URI::MailTo::EMAIL_REGEXP } + validates :organization_website, format: { with: URI::DEFAULT_PARSER.make_regexp, message: "should look like 'https://www.example.com'" }, allow_blank: true validate :email_not_already_used_by_organization validate :email_not_already_used_by_user diff --git a/app/views/account_requests/new.html.erb b/app/views/account_requests/new.html.erb index 2125b21a3e..63292f501a 100644 --- a/app/views/account_requests/new.html.erb +++ b/app/views/account_requests/new.html.erb @@ -75,7 +75,7 @@
- <%= f.input :organization_website %> + <%= f.input :organization_website, placeholder: "https://www.example.com" %>
diff --git a/spec/models/account_request_spec.rb b/spec/models/account_request_spec.rb index 48e03a80a2..539f61ff58 100644 --- a/spec/models/account_request_spec.rb +++ b/spec/models/account_request_spec.rb @@ -39,6 +39,9 @@ it { should allow_value(Faker::Internet.email).for(:email) } it { should_not allow_value("not_email").for(:email) } + it { should allow_value(Faker::Internet.url).for(:organization_website) } + it { should_not allow_value("www.example.com").for(:organization_website) } + context 'when the email provided is already used by an existing organization' do before do create(:organization, email: account_request.email)