mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 13:15:40 +02:00
Refactor registrars
- Reorganize views - Improve database structure - Use default translations - Combine tests
This commit is contained in:
parent
59e9b16dfa
commit
efb63399b2
27 changed files with 287 additions and 353 deletions
|
@ -58,12 +58,12 @@ module Admin
|
||||||
def registrar_params
|
def registrar_params
|
||||||
params.require(:registrar).permit(:name,
|
params.require(:registrar).permit(:name,
|
||||||
:reg_no,
|
:reg_no,
|
||||||
:street,
|
|
||||||
:city,
|
|
||||||
:state,
|
|
||||||
:zip,
|
|
||||||
:country_code,
|
|
||||||
:email,
|
:email,
|
||||||
|
:address_street,
|
||||||
|
:address_zip,
|
||||||
|
:address_city,
|
||||||
|
:address_state,
|
||||||
|
:address_country_code,
|
||||||
:phone,
|
:phone,
|
||||||
:website,
|
:website,
|
||||||
:code,
|
:code,
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Registrar < ActiveRecord::Base
|
||||||
|
|
||||||
delegate :balance, to: :cash_account, allow_nil: true
|
delegate :balance, to: :cash_account, allow_nil: true
|
||||||
|
|
||||||
validates :name, :reg_no, :country_code, :email, :code, presence: true
|
validates :name, :reg_no, :address_country_code, :email, :code, presence: true
|
||||||
validates :name, :code, uniqueness: true
|
validates :name, :code, uniqueness: true
|
||||||
validates :accounting_customer_code, presence: true
|
validates :accounting_customer_code, presence: true
|
||||||
validates :language, presence: true
|
validates :language, presence: true
|
||||||
|
@ -73,11 +73,11 @@ class Registrar < ActiveRecord::Base
|
||||||
buyer: self,
|
buyer: self,
|
||||||
buyer_name: name,
|
buyer_name: name,
|
||||||
buyer_reg_no: reg_no,
|
buyer_reg_no: reg_no,
|
||||||
buyer_country_code: country_code,
|
buyer_country_code: address_country_code,
|
||||||
buyer_state: state,
|
buyer_state: address_state,
|
||||||
buyer_street: street,
|
buyer_street: address_street,
|
||||||
buyer_city: city,
|
buyer_city: address_city,
|
||||||
buyer_zip: zip,
|
buyer_zip: address_zip,
|
||||||
buyer_phone: phone,
|
buyer_phone: phone,
|
||||||
buyer_url: website,
|
buyer_url: website,
|
||||||
buyer_email: email,
|
buyer_email: email,
|
||||||
|
@ -104,7 +104,7 @@ class Registrar < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def address
|
def address
|
||||||
[street, city, state, zip].reject(&:blank?).compact.join(', ')
|
[address_street, address_city, address_state, address_zip].reject(&:blank?).compact.join(', ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
@ -112,7 +112,7 @@ class Registrar < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def country
|
def country
|
||||||
Country.new(country_code)
|
Country.new(address_country_code)
|
||||||
end
|
end
|
||||||
|
|
||||||
def code=(code)
|
def code=(code)
|
||||||
|
|
|
@ -59,64 +59,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<%= render 'admin/registrars/form/address', f: f %>
|
||||||
<div class="col-md-8">
|
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-heading clearfix">
|
|
||||||
<div class="pull-left">
|
|
||||||
<%= t(:address) %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="panel-body">
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-md-4 control-label">
|
|
||||||
<%= f.label :street %>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-7">
|
|
||||||
<%= f.text_field(:street, class: 'form-control') %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-md-4 control-label">
|
|
||||||
<%= f.label :city %>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-7">
|
|
||||||
<%= f.text_field(:city, class: 'form-control') %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-md-4 control-label">
|
|
||||||
<%= f.label :state %>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-7">
|
|
||||||
<%= f.text_field(:state, class: 'form-control') %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-md-4 control-label">
|
|
||||||
<%= f.label :zip %>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-7">
|
|
||||||
<%= f.text_field(:zip, class: 'form-control') %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-md-4 control-label">
|
|
||||||
<%= f.label :country_code, t(:country) %>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-7">
|
|
||||||
<%= f.select(:country_code, SortedCountry.all_options(f.object.country_code), {}, class: 'form-control') %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= render 'admin/registrars/form/billing', f: f %>
|
<%= render 'admin/registrars/form/billing', f: f %>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
59
app/views/admin/registrars/form/_address.html.erb
Normal file
59
app/views/admin/registrars/form/_address.html.erb
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading clearfix">
|
||||||
|
<div class="pull-left">
|
||||||
|
<%= t '.header' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :street %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field :address_street, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :city %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field :address_city, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :state %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field :address_state, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :zip %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field :address_zip, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :address_country_code, t(:country) %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.select :address_country_code, SortedCountry.all_options(f.object.address_country_code), {}, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="text-muted"><%= t '.hint' %></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -28,23 +28,23 @@
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<%= render 'details', registrar: @registrar %>
|
<%= render 'admin/registrars/show/details', registrar: @registrar %>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<%= render 'contacts', registrar: @registrar %>
|
<%= render 'admin/registrars/show/contacts', registrar: @registrar %>
|
||||||
<%= render 'billing', registrar: @registrar %>
|
<%= render 'admin/registrars/show/billing', registrar: @registrar %>
|
||||||
<%= render 'preferences', registrar: registrar %>
|
<%= render 'admin/registrars/show/preferences', registrar: registrar %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<%= render 'users', registrar: @registrar %>
|
<%= render 'admin/registrars/show/users', registrar: @registrar %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<%= render 'white_ips', registrar: @registrar %>
|
<%= render 'admin/registrars/show/white_ips', registrar: @registrar %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,16 +5,16 @@
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
<dt><%= t(:country) %></dt>
|
<dt><%= Registrar.human_attribute_name :country %></dt>
|
||||||
<dd><%= @registrar.country %></dd>
|
<dd><%= @registrar.country %></dd>
|
||||||
|
|
||||||
<dt><%= t(:address) %></dt>
|
<dt><%= Registrar.human_attribute_name :address %></dt>
|
||||||
<dd><%= @registrar.address %></dd>
|
<dd><%= @registrar.address %></dd>
|
||||||
|
|
||||||
<dt><%= t(:contact_phone) %></dt>
|
<dt><%= Registrar.human_attribute_name :phone %></dt>
|
||||||
<dd><%= @registrar.phone %></dd>
|
<dd><%= @registrar.phone %></dd>
|
||||||
|
|
||||||
<dt><%= t(:contact_email) %></dt>
|
<dt><%= Registrar.human_attribute_name :email %></dt>
|
||||||
<dd><%= @registrar.email %></dd>
|
<dd><%= @registrar.email %></dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
|
@ -15,7 +15,7 @@
|
||||||
<dd><%= registrar.code %></dd>
|
<dd><%= registrar.code %></dd>
|
||||||
|
|
||||||
<dt><%= Registrar.human_attribute_name :balance %></dt>
|
<dt><%= Registrar.human_attribute_name :balance %></dt>
|
||||||
<dd><%= registrar.balance %></dd>
|
<dd><%= number_to_currency registrar.balance %></dd>
|
||||||
|
|
||||||
<dt><%= Registrar.human_attribute_name :website %></dt>
|
<dt><%= Registrar.human_attribute_name :website %></dt>
|
||||||
<dd><%= registrar.website %></dd>
|
<dd><%= registrar.website %></dd>
|
|
@ -13,7 +13,7 @@
|
||||||
%h3.panel-title= t(:general)
|
%h3.panel-title= t(:general)
|
||||||
.panel-body
|
.panel-body
|
||||||
%dl.dl-horizontal
|
%dl.dl-horizontal
|
||||||
%dt= t(:name)
|
%dt= Registrar.human_attribute_name :name
|
||||||
%dd= @registrar.name
|
%dd= @registrar.name
|
||||||
|
|
||||||
%dt= Registrar.human_attribute_name :reg_no
|
%dt= Registrar.human_attribute_name :reg_no
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
%dt= Registrar.human_attribute_name :vat_no
|
%dt= Registrar.human_attribute_name :vat_no
|
||||||
%dd= @registrar.vat_no
|
%dd= @registrar.vat_no
|
||||||
|
|
||||||
%dt= t(:id)
|
%dt= Registrar.human_attribute_name :code
|
||||||
%dd= @registrar.code
|
%dd= @registrar.code
|
||||||
|
|
||||||
.col-md-6
|
.col-md-6
|
||||||
|
@ -31,14 +31,14 @@
|
||||||
%h3.panel-title= t(:contact)
|
%h3.panel-title= t(:contact)
|
||||||
.panel-body
|
.panel-body
|
||||||
%dl.dl-horizontal
|
%dl.dl-horizontal
|
||||||
%dt= t(:country)
|
%dt= Registrar.human_attribute_name :country
|
||||||
%dd= @registrar.country
|
%dd= @registrar.country
|
||||||
|
|
||||||
%dt= t(:address)
|
%dt= Registrar.human_attribute_name :address
|
||||||
%dd= @registrar.address
|
%dd= @registrar.address
|
||||||
|
|
||||||
%dt= t(:contact_phone)
|
%dt= Registrar.human_attribute_name :phone
|
||||||
%dd= @registrar.phone
|
%dd= @registrar.phone
|
||||||
|
|
||||||
%dt= t(:contact_email)
|
%dt= Registrar.human_attribute_name :email
|
||||||
%dd= @registrar.email
|
%dd= @registrar.email
|
||||||
|
|
|
@ -13,12 +13,29 @@ en:
|
||||||
delete_btn: Delete
|
delete_btn: Delete
|
||||||
delete_btn_confirm: Are you sure you want delete registrar?
|
delete_btn_confirm: Are you sure you want delete registrar?
|
||||||
|
|
||||||
|
details:
|
||||||
|
header: Details
|
||||||
|
|
||||||
|
contacts:
|
||||||
|
header: Contacts
|
||||||
|
|
||||||
|
billing:
|
||||||
|
header: Billing
|
||||||
|
|
||||||
|
preferences:
|
||||||
|
header: Preferences
|
||||||
|
|
||||||
|
users:
|
||||||
|
header: API Users
|
||||||
|
new_btn: New API user
|
||||||
|
|
||||||
|
white_ips:
|
||||||
|
header: Whitelisted IPs
|
||||||
|
new_btn: New whitelisted IP
|
||||||
|
|
||||||
edit:
|
edit:
|
||||||
header: Edit registrar
|
header: Edit registrar
|
||||||
|
|
||||||
billing:
|
|
||||||
header: Billing
|
|
||||||
|
|
||||||
create:
|
create:
|
||||||
created: Registrar has been successfully created
|
created: Registrar has been successfully created
|
||||||
|
|
||||||
|
@ -33,6 +50,10 @@ en:
|
||||||
create_btn: Create registrar
|
create_btn: Create registrar
|
||||||
update_btn: Update registrar
|
update_btn: Update registrar
|
||||||
|
|
||||||
|
address:
|
||||||
|
header: Address
|
||||||
|
hint: Used as a billing address
|
||||||
|
|
||||||
billing:
|
billing:
|
||||||
header: Billing
|
header: Billing
|
||||||
no_reference_number_hint: Reference number will be generated automatically
|
no_reference_number_hint: Reference number will be generated automatically
|
||||||
|
@ -40,20 +61,3 @@ en:
|
||||||
|
|
||||||
preferences:
|
preferences:
|
||||||
header: Preferences
|
header: Preferences
|
||||||
|
|
||||||
details:
|
|
||||||
header: Details
|
|
||||||
|
|
||||||
contacts:
|
|
||||||
header: Contacts
|
|
||||||
|
|
||||||
preferences:
|
|
||||||
header: Preferences
|
|
||||||
|
|
||||||
users:
|
|
||||||
header: API Users
|
|
||||||
new_btn: New API user
|
|
||||||
|
|
||||||
white_ips:
|
|
||||||
header: Whitelisted IPs
|
|
||||||
new_btn: New whitelisted IP
|
|
||||||
|
|
|
@ -375,8 +375,6 @@ en:
|
||||||
choose: 'Choose...'
|
choose: 'Choose...'
|
||||||
created_before: 'Created before'
|
created_before: 'Created before'
|
||||||
created_after: 'Created after'
|
created_after: 'Created after'
|
||||||
contact_phone: 'Contact phone'
|
|
||||||
contact_email: 'Contact e-mail'
|
|
||||||
address_help: 'Street name, house no - apartment no, city, county, country, zip'
|
address_help: 'Street name, house no - apartment no, city, county, country, zip'
|
||||||
download: 'Download'
|
download: 'Download'
|
||||||
failed_to_create_certificate: 'Failed to create certificate!'
|
failed_to_create_certificate: 'Failed to create certificate!'
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
class PrefixRegistrarsAddressColumns < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_column :registrars, :street, :address_street
|
||||||
|
rename_column :registrars, :zip, :address_zip
|
||||||
|
rename_column :registrars, :city, :address_city
|
||||||
|
rename_column :registrars, :state, :address_state
|
||||||
|
rename_column :registrars, :country_code, :address_country_code
|
||||||
|
end
|
||||||
|
end
|
|
@ -2188,11 +2188,11 @@ CREATE TABLE public.registrars (
|
||||||
phone character varying,
|
phone character varying,
|
||||||
email character varying NOT NULL,
|
email character varying NOT NULL,
|
||||||
billing_email character varying,
|
billing_email character varying,
|
||||||
country_code character varying NOT NULL,
|
address_country_code character varying NOT NULL,
|
||||||
state character varying,
|
address_state character varying,
|
||||||
city character varying,
|
address_city character varying,
|
||||||
street character varying,
|
address_street character varying,
|
||||||
zip character varying,
|
address_zip character varying,
|
||||||
code character varying NOT NULL,
|
code character varying NOT NULL,
|
||||||
website character varying,
|
website character varying,
|
||||||
accounting_customer_code character varying NOT NULL,
|
accounting_customer_code character varying NOT NULL,
|
||||||
|
@ -4945,3 +4945,5 @@ INSERT INTO schema_migrations (version) VALUES ('20190328151838');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20190415120246');
|
INSERT INTO schema_migrations (version) VALUES ('20190415120246');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20190510090240');
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,12 @@ FactoryBot.define do
|
||||||
sequence(:name) { |n| "test#{n}" }
|
sequence(:name) { |n| "test#{n}" }
|
||||||
sequence(:code) { |n| "test#{n}" }
|
sequence(:code) { |n| "test#{n}" }
|
||||||
sequence(:reg_no) { |n| "test#{n}" }
|
sequence(:reg_no) { |n| "test#{n}" }
|
||||||
street 'test'
|
|
||||||
city 'test'
|
|
||||||
state 'test'
|
|
||||||
zip 'test'
|
|
||||||
email 'test@test.com'
|
email 'test@test.com'
|
||||||
country_code 'US'
|
address_street 'test'
|
||||||
|
address_zip 'test'
|
||||||
|
address_city 'test'
|
||||||
|
address_state 'test'
|
||||||
|
address_country_code 'US'
|
||||||
accounting_customer_code 'test'
|
accounting_customer_code 'test'
|
||||||
language 'en'
|
language 'en'
|
||||||
sequence(:reference_no) { |n| "1234#{n}" }
|
sequence(:reference_no) { |n| "1234#{n}" }
|
||||||
|
|
18
test/fixtures/registrars.yml
vendored
18
test/fixtures/registrars.yml
vendored
|
@ -3,11 +3,11 @@ bestnames:
|
||||||
reg_no: 1234
|
reg_no: 1234
|
||||||
code: bestnames
|
code: bestnames
|
||||||
email: info@bestnames.test
|
email: info@bestnames.test
|
||||||
street: Main Street
|
address_street: Main Street 1
|
||||||
zip: 12345
|
address_zip: 1234
|
||||||
city: New York
|
address_city: NY
|
||||||
state: New York
|
address_state: NY State
|
||||||
country_code: US
|
address_country_code: US
|
||||||
accounting_customer_code: bestnames
|
accounting_customer_code: bestnames
|
||||||
language: en
|
language: en
|
||||||
billing_email: billing@bestnames.test
|
billing_email: billing@bestnames.test
|
||||||
|
@ -19,18 +19,18 @@ goodnames:
|
||||||
reg_no: 12345
|
reg_no: 12345
|
||||||
code: goodnames
|
code: goodnames
|
||||||
email: info@goodnames.test
|
email: info@goodnames.test
|
||||||
country_code: DE
|
address_country_code: US
|
||||||
vat_no: DE123456789
|
vat_no: DE123456789
|
||||||
accounting_customer_code: goodnames
|
accounting_customer_code: goodnames
|
||||||
language: en
|
language: en
|
||||||
reference_no: 26
|
reference_no: 26
|
||||||
|
|
||||||
not_in_use:
|
not_in_use:
|
||||||
name: any
|
name: Not in use
|
||||||
reg_no: any
|
reg_no: any
|
||||||
code: any
|
code: any
|
||||||
email: any@example.com
|
email: any@example.com
|
||||||
country_code: US
|
address_country_code: US
|
||||||
vat_no: any
|
vat_no: any
|
||||||
accounting_customer_code: any
|
accounting_customer_code: any
|
||||||
language: en
|
language: en
|
||||||
|
@ -41,7 +41,7 @@ invalid:
|
||||||
reg_no: any
|
reg_no: any
|
||||||
code: another
|
code: another
|
||||||
email: any
|
email: any
|
||||||
country_code: US
|
address_country_code: US
|
||||||
vat_no: any
|
vat_no: any
|
||||||
accounting_customer_code: any
|
accounting_customer_code: any
|
||||||
language: en
|
language: en
|
||||||
|
|
|
@ -15,7 +15,7 @@ class RegistrarVATTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_apply_vat_rate_from_registry_when_registrar_is_local_vat_payer
|
def test_apply_vat_rate_from_registry_when_registrar_is_local_vat_payer
|
||||||
Setting.registry_country_code = 'US'
|
Setting.registry_country_code = 'US'
|
||||||
@registrar.country_code = 'US'
|
@registrar.address_country_code = 'US'
|
||||||
|
|
||||||
Registry.instance.stub(:vat_rate, BigDecimal('5.5')) do
|
Registry.instance.stub(:vat_rate, BigDecimal('5.5')) do
|
||||||
assert_equal BigDecimal('5.5'), @registrar.effective_vat_rate
|
assert_equal BigDecimal('5.5'), @registrar.effective_vat_rate
|
||||||
|
@ -32,13 +32,13 @@ class RegistrarVATTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_apply_vat_rate_from_registrar_when_registrar_is_foreign_vat_payer
|
def test_apply_vat_rate_from_registrar_when_registrar_is_foreign_vat_payer
|
||||||
Setting.registry_country_code = 'US'
|
Setting.registry_country_code = 'US'
|
||||||
@registrar.country_code = 'DE'
|
@registrar.address_country_code = 'DE'
|
||||||
@registrar.vat_rate = BigDecimal('5.6')
|
@registrar.vat_rate = BigDecimal('5.6')
|
||||||
assert_equal BigDecimal('5.6'), @registrar.effective_vat_rate
|
assert_equal BigDecimal('5.6'), @registrar.effective_vat_rate
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_require_vat_rate_when_registrar_is_foreign_vat_payer_and_vat_no_is_absent
|
def test_require_vat_rate_when_registrar_is_foreign_vat_payer_and_vat_no_is_absent
|
||||||
@registrar.country_code = 'DE'
|
@registrar.address_country_code = 'DE'
|
||||||
@registrar.vat_no = ''
|
@registrar.vat_no = ''
|
||||||
|
|
||||||
@registrar.vat_rate = ''
|
@registrar.vat_rate = ''
|
||||||
|
@ -50,7 +50,7 @@ class RegistrarVATTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_require_no_vat_rate_when_registrar_is_foreign_vat_payer_and_vat_no_is_present
|
def test_require_no_vat_rate_when_registrar_is_foreign_vat_payer_and_vat_no_is_present
|
||||||
@registrar.country_code = 'DE'
|
@registrar.address_country_code = 'DE'
|
||||||
@registrar.vat_no = 'valid'
|
@registrar.vat_no = 'valid'
|
||||||
|
|
||||||
@registrar.vat_rate = 1
|
@registrar.vat_rate = 1
|
||||||
|
@ -61,7 +61,7 @@ class RegistrarVATTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_vat_rate_validation
|
def test_vat_rate_validation
|
||||||
@registrar.country_code = 'DE'
|
@registrar.address_country_code = 'DE'
|
||||||
@registrar.vat_no = ''
|
@registrar.vat_no = ''
|
||||||
|
|
||||||
@registrar.vat_rate = -1
|
@registrar.vat_rate = -1
|
||||||
|
@ -78,7 +78,7 @@ class RegistrarVATTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_serializes_and_deserializes_vat_rate
|
def test_serializes_and_deserializes_vat_rate
|
||||||
@registrar.country_code = 'DE'
|
@registrar.address_country_code = 'DE'
|
||||||
@registrar.vat_rate = BigDecimal('25.5')
|
@registrar.vat_rate = BigDecimal('25.5')
|
||||||
@registrar.save!
|
@registrar.save!
|
||||||
@registrar.reload
|
@registrar.reload
|
||||||
|
|
|
@ -5,8 +5,8 @@ class RegistrarTest < ActiveSupport::TestCase
|
||||||
@registrar = registrars(:bestnames)
|
@registrar = registrars(:bestnames)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_default_fixture_is_valid
|
def test_valid_registrar_is_valid
|
||||||
assert @registrar.valid?, proc { @registrar.errors.full_messages }
|
assert valid_registrar.valid?, proc { valid_registrar.errors.full_messages }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_fixture_is_invalid
|
def test_invalid_fixture_is_invalid
|
||||||
|
@ -14,33 +14,33 @@ class RegistrarTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_without_name
|
def test_invalid_without_name
|
||||||
@registrar.name = ''
|
registrar = valid_registrar
|
||||||
assert @registrar.invalid?
|
registrar.name = ''
|
||||||
|
assert registrar.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_without_reg_no
|
def test_invalid_without_reg_no
|
||||||
@registrar.reg_no = ''
|
registrar = valid_registrar
|
||||||
assert @registrar.invalid?
|
registrar.reg_no = ''
|
||||||
|
assert registrar.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_without_email
|
def test_invalid_without_email
|
||||||
@registrar.email = ''
|
registrar = valid_registrar
|
||||||
assert @registrar.invalid?
|
registrar.email = ''
|
||||||
|
assert registrar.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_without_accounting_customer_code
|
def test_invalid_without_accounting_customer_code
|
||||||
@registrar.accounting_customer_code = ''
|
registrar = valid_registrar
|
||||||
assert @registrar.invalid?
|
registrar.accounting_customer_code = ''
|
||||||
end
|
assert registrar.invalid?
|
||||||
|
|
||||||
def test_invalid_without_country_code
|
|
||||||
@registrar.country_code = ''
|
|
||||||
assert @registrar.invalid?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_without_language
|
def test_invalid_without_language
|
||||||
@registrar.language = ''
|
registrar = valid_registrar
|
||||||
assert @registrar.invalid?
|
registrar.language = ''
|
||||||
|
assert registrar.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_has_default_language
|
def test_has_default_language
|
||||||
|
@ -56,7 +56,9 @@ class RegistrarTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_full_address
|
def test_full_address
|
||||||
assert_equal 'Main Street, New York, New York, 12345', @registrar.address
|
registrar = Registrar.new(address_street: 'Main Street 1', address_zip: '1234',
|
||||||
|
address_city: 'NY', address_state: 'NY State')
|
||||||
|
assert_equal 'Main Street 1, NY, NY State, 1234', registrar.address
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validates_reference_number_format
|
def test_validates_reference_number_format
|
||||||
|
@ -96,4 +98,10 @@ class RegistrarTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
Setting.days_to_keep_invoices_active = @original_days_to_keep_invoices_active_setting
|
Setting.days_to_keep_invoices_active = @original_days_to_keep_invoices_active_setting
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def valid_registrar
|
||||||
|
registrars(:bestnames)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,8 @@ class ContactVersionsTest < ApplicationSystemTestCase
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
|
@registrar = registrars(:bestnames)
|
||||||
|
|
||||||
create_contact_with_history
|
create_contact_with_history
|
||||||
sign_in users(:admin)
|
sign_in users(:admin)
|
||||||
end
|
end
|
||||||
|
@ -16,18 +18,13 @@ class ContactVersionsTest < ApplicationSystemTestCase
|
||||||
|
|
||||||
def create_contact_with_history
|
def create_contact_with_history
|
||||||
sql = <<-SQL.squish
|
sql = <<-SQL.squish
|
||||||
INSERT INTO registrars (id, name, reg_no, email, country_code, code,
|
|
||||||
accounting_customer_code, language, reference_no)
|
|
||||||
VALUES (75, 'test_registrar', 'test123', 'test@test.com', 'EE', 'TEST123',
|
|
||||||
'test123', 'en', '1234');
|
|
||||||
|
|
||||||
INSERT INTO contacts (id, code, email, auth_info, registrar_id)
|
INSERT INTO contacts (id, code, email, auth_info, registrar_id)
|
||||||
VALUES (75, 'test_code', 'test@inbox.test', '8b4d462aa04194ca78840a', 75);
|
VALUES (75, 'test_code', 'test@inbox.test', '8b4d462aa04194ca78840a', #{@registrar.id});
|
||||||
|
|
||||||
INSERT INTO log_contacts (item_type, item_id, event, whodunnit, object,
|
INSERT INTO log_contacts (item_type, item_id, event, whodunnit, object,
|
||||||
object_changes, created_at, session, children, ident_updated_at, uuid)
|
object_changes, created_at, session, children, ident_updated_at, uuid)
|
||||||
VALUES ('Contact', 75, 'update', '1-AdminUser',
|
VALUES ('Contact', 75, 'update', '1-AdminUser',
|
||||||
'{"id": 75, "code": "test_code", "auth_info": "8b4d462aa04194ca78840a", "registrar_id": 75, "old_field": "value"}',
|
'{"id": 75, "code": "test_code", "auth_info": "8b4d462aa04194ca78840a", "registrar_id": #{@registrar.id}, "old_field": "value"}',
|
||||||
'{"other_made_up_field": "value"}',
|
'{"other_made_up_field": "value"}',
|
||||||
'2018-04-23 15:50:48.113491', '2018-04-23 12:44:56',
|
'2018-04-23 15:50:48.113491', '2018-04-23 12:44:56',
|
||||||
'{"legal_documents":[null]}', null, null
|
'{"legal_documents":[null]}', null, null
|
||||||
|
@ -42,16 +39,20 @@ class ContactVersionsTest < ApplicationSystemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_removed_fields_are_not_causing_errors_in_index_view
|
def test_removed_fields_are_not_causing_errors_in_index_view
|
||||||
|
assert_equal 'Best Names', @registrar.name
|
||||||
|
|
||||||
visit admin_contact_versions_path
|
visit admin_contact_versions_path
|
||||||
assert_text 'test_registrar'
|
assert_text 'Best Names'
|
||||||
assert_text 'update 23.04.18, 18:50'
|
assert_text 'update 23.04.18, 18:50'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_removed_fields_are_not_causing_errors_in_details_view
|
def test_removed_fields_are_not_causing_errors_in_details_view
|
||||||
|
assert_equal 'Best Names', @registrar.name
|
||||||
|
|
||||||
version_id = Contact.find(75).versions.last
|
version_id = Contact.find(75).versions.last
|
||||||
visit admin_contact_version_path(version_id)
|
visit admin_contact_version_path(version_id)
|
||||||
|
|
||||||
assert_text 'test_registrar'
|
assert_text 'Best Names'
|
||||||
assert_text '23.04.18, 18:50 update 1-AdminUser'
|
assert_text '23.04.18, 18:50 update 1-AdminUser'
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -4,6 +4,8 @@ class DomainVersionsTest < ApplicationSystemTestCase
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
|
@registrar = registrars(:bestnames)
|
||||||
|
|
||||||
create_domain_with_history
|
create_domain_with_history
|
||||||
sign_in users(:admin)
|
sign_in users(:admin)
|
||||||
end
|
end
|
||||||
|
@ -16,22 +18,17 @@ class DomainVersionsTest < ApplicationSystemTestCase
|
||||||
|
|
||||||
def create_domain_with_history
|
def create_domain_with_history
|
||||||
sql = <<-SQL.squish
|
sql = <<-SQL.squish
|
||||||
INSERT INTO registrars (id, name, reg_no, email, country_code, code,
|
|
||||||
accounting_customer_code, language, reference_no)
|
|
||||||
VALUES (54, 'test_registrar', 'test123', 'test@test.com', 'EE', 'TEST123',
|
|
||||||
'test123', 'en', '1234');
|
|
||||||
|
|
||||||
INSERT INTO contacts (id, code, email, auth_info, registrar_id)
|
INSERT INTO contacts (id, code, email, auth_info, registrar_id)
|
||||||
VALUES (54, 'test_code', 'test@inbox.test', '8b4d462aa04194ca78840a', 54);
|
VALUES (54, 'test_code', 'test@inbox.test', '8b4d462aa04194ca78840a', #{@registrar.id});
|
||||||
|
|
||||||
INSERT INTO domains (id, registrar_id, valid_to, registrant_id,
|
INSERT INTO domains (id, registrar_id, valid_to, registrant_id,
|
||||||
transfer_code)
|
transfer_code)
|
||||||
VALUES (54, 54, '2018-06-23T12:14:02.732+03:00', 54, 'transfer_code');
|
VALUES (54, #{@registrar.id}, '2018-06-23T12:14:02.732+03:00', 54, 'transfer_code');
|
||||||
|
|
||||||
INSERT INTO log_domains (item_type, item_id, event, whodunnit, object,
|
INSERT INTO log_domains (item_type, item_id, event, whodunnit, object,
|
||||||
object_changes, created_at, session, children)
|
object_changes, created_at, session, children)
|
||||||
VALUES ('Domain', 54, 'update', '1-AdminUser',
|
VALUES ('Domain', 54, 'update', '1-AdminUser',
|
||||||
'{"id": 54, "registrar_id": 54, "valid_to": "2018-07-23T12:14:05.583+03:00", "registrant_id": 54, "transfer_code": "transfer_code", "valid_from": "2017-07-23T12:14:05.583+03:00"}',
|
'{"id": 54, "registrar_id": #{@registrar.id}, "valid_to": "2018-07-23T12:14:05.583+03:00", "registrant_id": 54, "transfer_code": "transfer_code", "valid_from": "2017-07-23T12:14:05.583+03:00"}',
|
||||||
'{"foo": "bar", "other_made_up_field": "value"}',
|
'{"foo": "bar", "other_made_up_field": "value"}',
|
||||||
'2018-04-23 15:50:48.113491', '2018-04-23 12:44:56',
|
'2018-04-23 15:50:48.113491', '2018-04-23 12:44:56',
|
||||||
'{"null_fracdmin_contacts":[108],"tech_contacts":[109],"nameservers":[],"dnskeys":[],"legal_documents":[null],"registrant":[1]}'
|
'{"null_fracdmin_contacts":[108],"tech_contacts":[109],"nameservers":[],"dnskeys":[],"legal_documents":[null],"registrant":[1]}'
|
||||||
|
@ -45,17 +42,21 @@ class DomainVersionsTest < ApplicationSystemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_removed_fields_are_not_causing_errors_in_index_view
|
def test_removed_fields_are_not_causing_errors_in_index_view
|
||||||
|
assert_equal 'Best Names', @registrar.name
|
||||||
|
|
||||||
visit admin_domain_versions_path
|
visit admin_domain_versions_path
|
||||||
|
|
||||||
assert_text 'test_registrar'
|
assert_text 'Best Names'
|
||||||
assert_text 'test_registrar update 23.04.18, 18:50'
|
assert_text 'Best Names update 23.04.18, 18:50'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_removed_fields_are_not_causing_errors_in_details_view
|
def test_removed_fields_are_not_causing_errors_in_details_view
|
||||||
|
assert_equal 'Best Names', @registrar.name
|
||||||
|
|
||||||
version_id = Domain.find(54).versions.last
|
version_id = Domain.find(54).versions.last
|
||||||
visit admin_domain_version_path(version_id)
|
visit admin_domain_version_path(version_id)
|
||||||
|
|
||||||
assert_text 'test_registrar'
|
assert_text 'Best Names'
|
||||||
assert_text '23.04.18, 18:50 update 1-AdminUser'
|
assert_text '23.04.18, 18:50 update 1-AdminUser'
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,30 +0,0 @@
|
||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class AdminAreaDeleteRegistrarTest < ApplicationSystemTestCase
|
|
||||||
setup do
|
|
||||||
sign_in users(:admin)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_can_be_deleted_when_not_in_use
|
|
||||||
visit admin_registrar_url(registrars(:not_in_use))
|
|
||||||
|
|
||||||
assert_difference 'Registrar.count', -1 do
|
|
||||||
click_link_or_button 'Delete'
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_current_path admin_registrars_path
|
|
||||||
assert_text 'Registrar has been successfully deleted'
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_cannot_be_deleted_when_in_use
|
|
||||||
registrar = registrars(:bestnames)
|
|
||||||
visit admin_registrar_url(registrar)
|
|
||||||
|
|
||||||
assert_no_difference 'Registrar.count' do
|
|
||||||
click_link_or_button 'Delete'
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_current_path admin_registrar_path(registrar)
|
|
||||||
assert_text 'Cannot delete record because dependent domains exist'
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,26 +0,0 @@
|
||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class AdminAreaRegistrarDetailsTest < ApplicationSystemTestCase
|
|
||||||
include ActionView::Helpers::NumberHelper
|
|
||||||
|
|
||||||
setup do
|
|
||||||
sign_in users(:admin)
|
|
||||||
@registrar = registrars(:bestnames)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_registrar_details
|
|
||||||
@registrar.accounting_customer_code = 'US0001'
|
|
||||||
@registrar.vat_no = 'US12345'
|
|
||||||
@registrar.vat_rate = 5
|
|
||||||
@registrar.language = 'en'
|
|
||||||
@registrar.billing_email = 'billing@bestnames.test'
|
|
||||||
@registrar.save(validate: false)
|
|
||||||
|
|
||||||
visit admin_registrar_path(@registrar)
|
|
||||||
assert_text 'Accounting customer code US0001'
|
|
||||||
assert_text 'VAT number US12345'
|
|
||||||
assert_text 'VAT rate 5.0%'
|
|
||||||
assert_text 'Language English'
|
|
||||||
assert_text 'billing@bestnames.test'
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,69 +0,0 @@
|
||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class AdminAreaEditRegistrarTest < ApplicationSystemTestCase
|
|
||||||
setup do
|
|
||||||
sign_in users(:admin)
|
|
||||||
@registrar = registrars(:bestnames)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_attributes_update
|
|
||||||
visit admin_registrar_path(@registrar)
|
|
||||||
click_link_or_button 'Edit'
|
|
||||||
|
|
||||||
fill_in 'Name', with: 'new name'
|
|
||||||
fill_in 'Reg no', with: '4727673'
|
|
||||||
fill_in 'Contact phone', with: '2570937'
|
|
||||||
fill_in 'Website', with: 'http://new.example.com'
|
|
||||||
fill_in 'Contact e-mail', with: 'new@example.com'
|
|
||||||
|
|
||||||
fill_in 'Street', with: 'new street'
|
|
||||||
fill_in 'Zip', with: 'new zip'
|
|
||||||
fill_in 'City', with: 'new city'
|
|
||||||
fill_in 'State / Province', with: 'new state'
|
|
||||||
select 'Germany', from: 'Country'
|
|
||||||
|
|
||||||
fill_in 'VAT number', with: '2386449'
|
|
||||||
fill_in 'Accounting customer code', with: '866477'
|
|
||||||
fill_in 'Billing email', with: 'new-billing@example.com'
|
|
||||||
|
|
||||||
select 'Estonian', from: 'Language'
|
|
||||||
click_link_or_button 'Update registrar'
|
|
||||||
|
|
||||||
@registrar.reload
|
|
||||||
assert_equal 'new name', @registrar.name
|
|
||||||
assert_equal '4727673', @registrar.reg_no
|
|
||||||
assert_equal '2570937', @registrar.phone
|
|
||||||
assert_equal 'http://new.example.com', @registrar.website
|
|
||||||
assert_equal 'new@example.com', @registrar.email
|
|
||||||
|
|
||||||
assert_equal 'new street', @registrar.street
|
|
||||||
assert_equal 'new zip', @registrar.zip
|
|
||||||
assert_equal 'new city', @registrar.city
|
|
||||||
assert_equal 'new state', @registrar.state
|
|
||||||
assert_equal Country.new('DE'), @registrar.country
|
|
||||||
|
|
||||||
assert_equal '2386449', @registrar.vat_no
|
|
||||||
assert_equal '866477', @registrar.accounting_customer_code
|
|
||||||
assert_equal 'new-billing@example.com', @registrar.billing_email
|
|
||||||
|
|
||||||
assert_equal 'et', @registrar.language
|
|
||||||
assert_current_path admin_registrar_path(@registrar)
|
|
||||||
assert_text 'Registrar has been successfully updated'
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_code_cannot_be_changed
|
|
||||||
visit admin_registrar_path(@registrar)
|
|
||||||
click_link_or_button 'Edit'
|
|
||||||
assert_no_field 'Code'
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_fails_gracefully
|
|
||||||
visit admin_registrar_path(@registrar)
|
|
||||||
click_link_or_button 'Edit'
|
|
||||||
fill_in 'Name', with: 'Good Names'
|
|
||||||
click_link_or_button 'Update registrar'
|
|
||||||
|
|
||||||
assert_field 'Name', with: 'Good Names'
|
|
||||||
assert_text 'Name has already been taken'
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,50 +0,0 @@
|
||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class AdminAreaNewRegistrarTest < ApplicationSystemTestCase
|
|
||||||
setup do
|
|
||||||
sign_in users(:admin)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_new_registrar_creation_with_required_params
|
|
||||||
visit admin_registrars_url
|
|
||||||
click_link_or_button 'New registrar'
|
|
||||||
|
|
||||||
fill_in 'Name', with: 'Brand new names'
|
|
||||||
fill_in 'Reg no', with: '55555555'
|
|
||||||
fill_in 'Contact e-mail', with: 'test@example.com'
|
|
||||||
select 'United States', from: 'Country'
|
|
||||||
fill_in 'Accounting customer code', with: 'test'
|
|
||||||
fill_in 'Code', with: 'test'
|
|
||||||
|
|
||||||
assert_difference 'Registrar.count' do
|
|
||||||
click_link_or_button 'Create registrar'
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_current_path admin_registrar_path(Registrar.last)
|
|
||||||
assert_text 'Registrar has been successfully created'
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_fails_gracefully
|
|
||||||
visit admin_registrars_url
|
|
||||||
click_link_or_button 'New registrar'
|
|
||||||
|
|
||||||
fill_in 'Name', with: 'Best Names'
|
|
||||||
fill_in 'Reg no', with: '55555555'
|
|
||||||
fill_in 'Contact e-mail', with: 'test@example.com'
|
|
||||||
fill_in 'Accounting customer code', with: 'test'
|
|
||||||
fill_in 'Code', with: 'test'
|
|
||||||
|
|
||||||
assert_no_difference 'Registrar.count' do
|
|
||||||
click_link_or_button 'Create registrar'
|
|
||||||
end
|
|
||||||
assert_field 'Name', with: 'Best Names'
|
|
||||||
assert_text 'Name has already been taken'
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_pre_populated_default_language
|
|
||||||
Setting.default_language = 'en'
|
|
||||||
visit admin_registrars_url
|
|
||||||
click_link_or_button 'New registrar'
|
|
||||||
assert_field 'Language', with: 'en'
|
|
||||||
end
|
|
||||||
end
|
|
84
test/system/admin_area/registrars_test.rb
Normal file
84
test/system/admin_area/registrars_test.rb
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class AdminRegistrarsSystemTest < ApplicationSystemTestCase
|
||||||
|
include ActionView::Helpers::NumberHelper
|
||||||
|
|
||||||
|
setup do
|
||||||
|
@registrar = registrars(:bestnames)
|
||||||
|
sign_in users(:admin)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_creates_new_registrar
|
||||||
|
assert_nil Registrar.find_by(name: 'New name')
|
||||||
|
|
||||||
|
visit admin_registrars_path
|
||||||
|
click_on 'New registrar'
|
||||||
|
|
||||||
|
fill_in 'Name', with: 'New name'
|
||||||
|
fill_in 'Reg no', with: '55555555'
|
||||||
|
fill_in 'Contact e-mail', with: 'any@registrar.test'
|
||||||
|
select 'United States', from: 'Country'
|
||||||
|
fill_in 'Accounting customer code', with: 'test'
|
||||||
|
fill_in 'Code', with: 'test'
|
||||||
|
click_on 'Create registrar'
|
||||||
|
|
||||||
|
assert_text 'Registrar has been successfully created'
|
||||||
|
assert_text 'New name'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_updates_registrar
|
||||||
|
assert_not_equal 'New name', @registrar.name
|
||||||
|
|
||||||
|
visit admin_registrar_path(@registrar)
|
||||||
|
click_link_or_button 'Edit'
|
||||||
|
fill_in 'Name', with: 'New name'
|
||||||
|
click_link_or_button 'Update registrar'
|
||||||
|
|
||||||
|
assert_text 'Registrar has been successfully updated'
|
||||||
|
assert_text 'New name'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_deletes_registrar
|
||||||
|
registrar = registrars(:not_in_use)
|
||||||
|
assert_equal 'Not in use', registrar.name
|
||||||
|
|
||||||
|
visit admin_registrar_path(registrar)
|
||||||
|
click_on 'Delete'
|
||||||
|
|
||||||
|
assert_text 'Registrar has been successfully deleted'
|
||||||
|
assert_no_text 'Not in use'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_registrar_cannot_be_deleted_when_in_use
|
||||||
|
visit admin_registrar_url(@registrar)
|
||||||
|
click_on 'Delete'
|
||||||
|
assert_text 'Cannot delete record because dependent domains exist'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_pre_populates_default_language_upon_creation
|
||||||
|
Setting.default_language = 'en'
|
||||||
|
visit new_admin_registrar_path
|
||||||
|
assert_field 'Language', with: 'en'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_code_cannot_be_edited
|
||||||
|
visit edit_admin_registrar_path(@registrar)
|
||||||
|
assert_no_field 'Code'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_shows_registrar_details
|
||||||
|
@registrar.accounting_customer_code = 'US0001'
|
||||||
|
@registrar.vat_no = 'US12345'
|
||||||
|
@registrar.vat_rate = 5
|
||||||
|
@registrar.language = 'en'
|
||||||
|
@registrar.billing_email = 'billing@bestnames.test'
|
||||||
|
@registrar.save(validate: false)
|
||||||
|
|
||||||
|
visit admin_registrar_path(@registrar)
|
||||||
|
assert_text 'Accounting customer code US0001'
|
||||||
|
assert_text 'VAT number US12345'
|
||||||
|
assert_text "VAT rate #{number_to_percentage(5, precision: 1)}"
|
||||||
|
assert_text 'Language English'
|
||||||
|
assert_text 'billing@bestnames.test'
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue