Skip to content

Commit

Permalink
Merge pull request #439 from internetee/registry-432
Browse files Browse the repository at this point in the history
Registry 432
  • Loading branch information
teadur authored Apr 5, 2017
2 parents e361bf4 + d62a4e8 commit 49c6a97
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 18 deletions.
3 changes: 0 additions & 3 deletions app/assets/javascripts/registrar-manifest.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#= require jquery
#= require jquery_ujs
#= require jquery.validate
#= require jquery.validate.additional-methods
#= require turbolinks
#= require bootstrap-sprockets
#= require typeahead.bundle.min
#= require jquery.nested_attributes
#= require shared/jquery.validate.bootstrap
#= require jquery-ui/datepicker
#= require select2

Expand Down
4 changes: 0 additions & 4 deletions app/assets/javascripts/registrar/application.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
$(document).on 'page:change', ->
# client side validate all forms
$('form').each ->
$(this).validate()

$('.js-contact-form').on 'restoreDefault', (e) ->
form = $(e.target)
form.find('.js-ident-tip').hide()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@ $.validator.setDefaults
else
error.insertAfter element
return

jQuery.validator.addMethod 'lax_email', ((value, element) ->
@optional(element) or (value.match(new RegExp("@", "g")) || []).length == 1
), 'Please enter a valid email address.'
2 changes: 1 addition & 1 deletion app/views/admin/admin_users/_form.haml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
.col-md-4.control-label
= f.label :email
.col-md-8
= f.text_field(:email, class: 'form-control', lax_email: true)
= f.email_field :email, class: 'form-control'
.form-group
.col-md-4.control-label
= f.label :country_code, t(:country)
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/mail_templates/_form.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
.col-md-4.control-label
= f.label :from
.col-md-7
= f.text_field(:from, class: 'form-control', lax_email: true)
= f.email_field :from, class: 'form-control'
.form-group
.col-md-4.control-label
= f.label :cc
.col-md-7
= f.text_field(:cc, class: 'form-control', lax_email: true)
= f.email_field :cc, class: 'form-control'
.form-group
.col-md-4.control-label
= f.label :bcc
.col-md-7
= f.text_field(:bcc, class: 'form-control', lax_email: true)
= f.email_field :bcc, class: 'form-control'
.form-group
.col-md-12
= f.label :body, t(:html_body)
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/registrars/_form.haml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
.col-md-4.control-label
= f.label :email
.col-md-7
= f.text_field(:email, class: 'form-control', lax_email: true)
= f.email_field :email, class: 'form-control'
.form-group
.col-md-4.control-label
= f.label :billing_email
.col-md-7
= f.text_field(:billing_email, class: 'form-control', lax_email: true)
= f.email_field :billing_email, class: 'form-control'

.row
.col-md-8
Expand Down
2 changes: 1 addition & 1 deletion app/views/registrar/contacts/form/_general.haml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
.col-md-3.control-label
= f.label :email, t(:email) + '*'
.col-md-7
= f.text_field :email, class: 'form-control', required: true, lax_email: true
= f.email_field :email, class: 'form-control', required: true

.form-group
.col-md-3.control-label
Expand Down
10 changes: 10 additions & 0 deletions spec/requests/admin/registrars/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
expect(registrar.website).to eq('test')
end

it 'saves email' do
post admin_registrars_path, { registrar: attributes_for(:registrar, email: '[email protected]') }
expect(registrar.email).to eq('[email protected]')
end

it 'saves billing email' do
post admin_registrars_path, { registrar: attributes_for(:registrar, billing_email: '[email protected]') }
expect(registrar.billing_email).to eq('[email protected]')
end

it 'redirects to :show' do
post admin_registrars_path, { registrar: attributes_for(:registrar) }
expect(response).to redirect_to admin_registrar_path(registrar)
Expand Down
18 changes: 18 additions & 0 deletions spec/requests/admin/registrars/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
expect(registrar.website).to eq('new-website')
end

it 'updates email' do
registrar = create(:registrar, email: '[email protected]')

patch admin_registrar_path(registrar), registrar: attributes_for(:registrar, email: '[email protected]')
registrar.reload

expect(registrar.email).to eq('[email protected]')
end

it 'updates billing email' do
registrar = create(:registrar, billing_email: '[email protected]')

patch admin_registrar_path(registrar), registrar: attributes_for(:registrar, billing_email: '[email protected]')
registrar.reload

expect(registrar.billing_email).to eq('[email protected]')
end

it 'redirects to :show' do
registrar = create(:registrar)

Expand Down

0 comments on commit 49c6a97

Please sign in to comment.