Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4423 format account request org websites #4427

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/account_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 'http://www.example.com'" }, allow_blank: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default should be https, not http. Pretty much every website in existence is on httpsnow.


validate :email_not_already_used_by_organization
validate :email_not_already_used_by_user
Expand Down
2 changes: 1 addition & 1 deletion app/views/account_requests/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</div>

<div class="form-inputs">
<%= f.input :organization_website %>
<%= f.input :organization_website, placeholder: "http://www.example.com" %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

</div>

<div class="form-inputs">
Expand Down
3 changes: 3 additions & 0 deletions spec/models/account_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down