mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Merge pull request #1208 from internetee/make-registrar-address-state-and-zip-optional
Make registrar address zip and state optional
This commit is contained in:
commit
eed255fa20
7 changed files with 27 additions and 24 deletions
|
@ -15,8 +15,7 @@ class Registrar < ActiveRecord::Base
|
|||
|
||||
validates :name, :reg_no, :email, :code, presence: true
|
||||
validates :name, :code, uniqueness: true
|
||||
validates :address_street, :address_zip, :address_city, :address_state, :address_country_code,
|
||||
presence: true
|
||||
validates :address_street, :address_city, :address_country_code, presence: true
|
||||
validates :accounting_customer_code, presence: true
|
||||
validates :language, presence: true
|
||||
validates :reference_no, format: Billing::ReferenceNo::REGEXP
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<%= f.label :state, for: :registrar_address_state %>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<%= f.text_field :address_state, required: true, class: 'form-control' %>
|
||||
<%= f.text_field :address_state, class: 'form-control' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
|||
<%= f.label :zip, for: :registrar_address_zip %>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<%= f.text_field :address_zip, required: true, class: 'form-control' %>
|
||||
<%= f.text_field :address_zip, class: 'form-control' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class ChangeRegistrarsAddressStateAndZipToNull < ActiveRecord::Migration
|
||||
def change
|
||||
change_column_null :registrars, :address_state, true
|
||||
change_column_null :registrars, :address_zip, true
|
||||
end
|
||||
end
|
|
@ -2189,10 +2189,10 @@ CREATE TABLE public.registrars (
|
|||
email character varying NOT NULL,
|
||||
billing_email character varying,
|
||||
address_country_code character varying NOT NULL,
|
||||
address_state character varying NOT NULL,
|
||||
address_state character varying,
|
||||
address_city character varying NOT NULL,
|
||||
address_street character varying NOT NULL,
|
||||
address_zip character varying NOT NULL,
|
||||
address_zip character varying,
|
||||
code character varying NOT NULL,
|
||||
website character varying,
|
||||
accounting_customer_code character varying NOT NULL,
|
||||
|
@ -4966,3 +4966,5 @@ INSERT INTO schema_migrations (version) VALUES ('20190510090240');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20190510102549');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20190520093231');
|
||||
|
||||
|
|
|
@ -5,9 +5,7 @@ FactoryBot.define do
|
|||
sequence(:reg_no) { |n| "test#{n}" }
|
||||
email 'test@test.com'
|
||||
address_street 'test'
|
||||
address_zip 'test'
|
||||
address_city 'test'
|
||||
address_state 'test'
|
||||
address_country_code 'US'
|
||||
accounting_customer_code 'test'
|
||||
language 'en'
|
||||
|
|
8
test/fixtures/registrars.yml
vendored
8
test/fixtures/registrars.yml
vendored
|
@ -4,9 +4,7 @@ bestnames:
|
|||
code: bestnames
|
||||
email: info@bestnames.test
|
||||
address_street: Main Street 1
|
||||
address_zip: 1234
|
||||
address_city: NY
|
||||
address_state: NY State
|
||||
address_country_code: US
|
||||
accounting_customer_code: bestnames
|
||||
language: en
|
||||
|
@ -20,9 +18,7 @@ goodnames:
|
|||
code: goodnames
|
||||
email: info@goodnames.test
|
||||
address_street: Main Street 1
|
||||
address_zip: 1234
|
||||
address_city: NY
|
||||
address_state: NY State
|
||||
address_country_code: US
|
||||
vat_no: DE123456789
|
||||
accounting_customer_code: goodnames
|
||||
|
@ -35,9 +31,7 @@ not_in_use:
|
|||
code: any
|
||||
email: any@example.com
|
||||
address_street: Main Street 1
|
||||
address_zip: 1234
|
||||
address_city: NY
|
||||
address_state: NY State
|
||||
address_country_code: US
|
||||
vat_no: any
|
||||
accounting_customer_code: any
|
||||
|
@ -50,9 +44,7 @@ invalid:
|
|||
code: another
|
||||
email: any
|
||||
address_street: Main Street 1
|
||||
address_zip: 1234
|
||||
address_city: NY
|
||||
address_state: NY State
|
||||
address_country_code: US
|
||||
vat_no: any
|
||||
accounting_customer_code: any
|
||||
|
|
|
@ -93,16 +93,22 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
Setting.days_to_keep_invoices_active = @original_days_to_keep_invoices_active_setting
|
||||
end
|
||||
|
||||
def test_invalid_without_address
|
||||
def test_invalid_without_address_street
|
||||
registrar = valid_registrar
|
||||
address_parts = %i[street zip city state country_code]
|
||||
registrar.address_street = ''
|
||||
assert registrar.invalid?
|
||||
end
|
||||
|
||||
address_parts.each do |address_part|
|
||||
attribute_name = "address_#{address_part}"
|
||||
registrar.public_send("#{attribute_name}=", '')
|
||||
assert registrar.invalid?, "#{attribute_name} should be required"
|
||||
registrar.public_send("#{attribute_name}=", 'some')
|
||||
end
|
||||
def test_invalid_without_address_city
|
||||
registrar = valid_registrar
|
||||
registrar.address_city = ''
|
||||
assert registrar.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_address_country_code
|
||||
registrar = valid_registrar
|
||||
registrar.address_country_code = ''
|
||||
assert registrar.invalid?
|
||||
end
|
||||
|
||||
def test_full_address
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue