diff --git a/.reek b/.reek index 0d5c66aa3..d7d39a198 100644 --- a/.reek +++ b/.reek @@ -191,7 +191,6 @@ DuplicateMethodCall: - Registrant::SessionsController#mid_status - Registrant::WhoisController#index - Registrar::AccountActivitiesController#index - - Registrar::BaseController#check_ip - Registrar::ContactsController#download_list - Registrar::ContactsController#index - Registrar::ContactsController#normalize_search_parameters @@ -667,7 +666,6 @@ TooManyStatements: - Registrant::SessionsController#mid - Registrant::SessionsController#mid_status - Registrar::AccountActivitiesController#index - - Registrar::BaseController#check_ip - Registrar::ContactsController#download_list - Registrar::ContactsController#index - Registrar::ContactsController#normalize_search_parameters diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e76d8a12..472c5545d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +19.03.2018 +* EPP transfer and REPP bulk transfer reuses contact objects [#746](https://github.com/internetee/registry/issues/746) +* Gems: Rack (1.6.9) and Rack-protection (1.5.5) update [#768](https://github.com/internetee/registry/issues/768) +* Removal of unused database tables [#756](https://github.com/internetee/registry/issues/756) +* Removal of unused date format [#764](https://github.com/internetee/registry/pull/764) +* Removal of billing postal address [#747](https://github.com/internetee/registry/issues/747) + 06.03.2018 * BUG: Transfer poll message now returns affected domain name [#694](https://github.com/internetee/registry/issues/694) * BUG: Successful REPP bulk transfer returns info about transfered domains [#693](https://github.com/internetee/registry/issues/693) diff --git a/Gemfile.lock b/Gemfile.lock index ed559f465..6d9105baf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -160,6 +160,7 @@ GEM unicode_utils (~> 1.4) crack (0.4.3) safe_yaml (~> 1.0.0) + crass (1.0.3) daemons (1.2.4) daemons-rails (1.2.1) daemons @@ -247,7 +248,8 @@ GEM activesupport (>= 3.0.0) libxml-ruby (3.0.0) liquid (3.0.6) - loofah (2.0.3) + loofah (2.2.2) + crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.6.6) mime-types (>= 1.16, < 4) diff --git a/app/assets/javascripts/admin-manifest.coffee b/app/assets/javascripts/admin-manifest.coffee index 909cd191c..dd99c1932 100644 --- a/app/assets/javascripts/admin-manifest.coffee +++ b/app/assets/javascripts/admin-manifest.coffee @@ -9,6 +9,7 @@ #= require select2 #= require jquery.doubleScroll #= require datepicker +#= require spell_check #= require admin/application #= require admin/app #= require_tree ./admin diff --git a/app/assets/javascripts/registrant-manifest.coffee b/app/assets/javascripts/registrant-manifest.coffee index eb7577e02..84f95374a 100644 --- a/app/assets/javascripts/registrant-manifest.coffee +++ b/app/assets/javascripts/registrant-manifest.coffee @@ -4,4 +4,5 @@ #= require jquery-ui/datepicker #= require select2 #= require datepicker +#= require spell_check #= require shared/general diff --git a/app/assets/javascripts/registrar-manifest.coffee b/app/assets/javascripts/registrar-manifest.coffee index 656b5cb18..5c4a58df6 100644 --- a/app/assets/javascripts/registrar-manifest.coffee +++ b/app/assets/javascripts/registrar-manifest.coffee @@ -6,6 +6,7 @@ #= require jquery-ui/datepicker #= require select2 #= require datepicker +#= require spell_check #= require shared/general #= require registrar/autocomplete #= require registrar/application diff --git a/app/assets/javascripts/spell_check.js b/app/assets/javascripts/spell_check.js new file mode 100644 index 000000000..7c04ab071 --- /dev/null +++ b/app/assets/javascripts/spell_check.js @@ -0,0 +1,12 @@ +(function() { + function disableSpellCheck() { + let selector = 'input[type=text], textarea'; + let textFields = document.querySelectorAll(selector); + + for (let field of textFields) { + field.spellcheck = false; + } + } + + disableSpellCheck(); +})(); diff --git a/app/controllers/admin/registrars_controller.rb b/app/controllers/admin/registrars_controller.rb index c8ec169f8..e919bdb25 100644 --- a/app/controllers/admin/registrars_controller.rb +++ b/app/controllers/admin/registrars_controller.rb @@ -43,8 +43,13 @@ module Admin end def destroy - @registrar.destroy! - redirect_to admin_registrars_url, notice: t('.deleted') + if @registrar.destroy + flash[:notice] = t('.deleted') + redirect_to admin_registrars_url + else + flash[:alert] = @registrar.errors.full_messages.first + redirect_to admin_registrar_url(@registrar) + end end private @@ -64,7 +69,6 @@ module Admin :email, :phone, :website, - :billing_email, :code, :test_registrar, :vat_no, diff --git a/app/controllers/registrar/payments_controller.rb b/app/controllers/registrar/payments_controller.rb index 696dbbc7e..18c892ea7 100644 --- a/app/controllers/registrar/payments_controller.rb +++ b/app/controllers/registrar/payments_controller.rb @@ -3,7 +3,7 @@ class Registrar protect_from_forgery except: :back skip_authorization_check # actually anyone can pay, no problems at all - skip_before_action :authenticate_user!, :check_ip, only: [:back] + skip_before_action :authenticate_user!, :check_ip_restriction, only: [:back] before_action :check_bank # to handle existing model we should diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 9cba29faf..d539e01f2 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -14,9 +14,10 @@ class Registrar < ActiveRecord::Base delegate :balance, to: :cash_account, allow_nil: true validates :name, :reg_no, :country_code, :email, :code, presence: true - validates :name, :reg_no, :reference_no, :code, uniqueness: true + validates :name, :reference_no, :code, uniqueness: true validates :accounting_customer_code, presence: true validates :language, presence: true + validate :forbid_special_code validates :vat_rate, presence: true, if: 'foreign_vat_payer? && vat_no.blank?' validates :vat_rate, absence: true, if: :home_vat_payer? diff --git a/app/views/admin/bank_transactions/show.haml b/app/views/admin/bank_transactions/show.haml index 4133386e5..60515200a 100644 --- a/app/views/admin/bank_transactions/show.haml +++ b/app/views/admin/bank_transactions/show.haml @@ -41,7 +41,7 @@ %dt= t(:currency) %dd= @bank_transaction.currency - %dt= t(:reference_no) + %dt= BankTransaction.human_attribute_name :reference_no %dd= @bank_transaction.reference_no %dt= t(:paid_at) diff --git a/app/views/admin/registrars/_contacts.html.erb b/app/views/admin/registrars/_contacts.html.erb new file mode 100644 index 000000000..190e48458 --- /dev/null +++ b/app/views/admin/registrars/_contacts.html.erb @@ -0,0 +1,24 @@ +
+
+ <%= t '.header' %> +
+ +
+
+
<%= t(:country) %>
+
<%= @registrar.country %>
+ +
<%= t(:address) %>
+
<%= @registrar.address %>
+ +
<%= t(:contact_phone) %>
+
<%= @registrar.phone %>
+ +
<%= t(:contact_email) %>
+
<%= @registrar.email %>
+ +
<%= Registrar.human_attribute_name :billing_email %>
+
<%= @registrar.billing_email %>
+
+
+
diff --git a/app/views/admin/registrars/_details.html.erb b/app/views/admin/registrars/_details.html.erb new file mode 100644 index 000000000..c640075ba --- /dev/null +++ b/app/views/admin/registrars/_details.html.erb @@ -0,0 +1,27 @@ +
+
+ <%= t '.header' %> +
+ +
+
+
<%= Registrar.human_attribute_name :name %>
+
<%= registrar.name %>
+ +
<%= Registrar.human_attribute_name :reg_no %>
+
<%= registrar.reg_no %>
+ +
<%= Registrar.human_attribute_name :reference_no %>
+
<%= registrar.reference_no %>
+ +
<%= Registrar.human_attribute_name :code %>
+
<%= registrar.code %>
+ +
<%= Registrar.human_attribute_name :balance %>
+
<%= registrar.balance %>
+ +
<%= Registrar.human_attribute_name :website %>
+
<%= registrar.website %>
+
+
+
diff --git a/app/views/admin/registrars/show/_preferences.html.erb b/app/views/admin/registrars/_preferences.html.erb similarity index 100% rename from app/views/admin/registrars/show/_preferences.html.erb rename to app/views/admin/registrars/_preferences.html.erb diff --git a/app/views/admin/registrars/_users.html.erb b/app/views/admin/registrars/_users.html.erb new file mode 100644 index 000000000..f182e4615 --- /dev/null +++ b/app/views/admin/registrars/_users.html.erb @@ -0,0 +1,28 @@ +
+
+ <%= t '.header' %> +
+ + + + + + + + + + + <% registrar.api_users.each do |user| %> + + + + + <% end %> + +
<%= ApiUser.human_attribute_name :username %><%= ApiUser.human_attribute_name :active %>
<%= link_to(user, [:admin, user]) %><%= user.active %>
+ + +
diff --git a/app/views/admin/registrars/_white_ips.html.erb b/app/views/admin/registrars/_white_ips.html.erb new file mode 100644 index 000000000..c86c85eb9 --- /dev/null +++ b/app/views/admin/registrars/_white_ips.html.erb @@ -0,0 +1,38 @@ +
+
+ <%= t '.header' %> +
+ + + + + + + + + + + + <% registrar.white_ips.each do |white_ip| %> + + + + + + <% end %> + +
<%= WhiteIp.human_attribute_name :ipv4 %><%= WhiteIp.human_attribute_name :ipv6 %><%= WhiteIp.human_attribute_name :interfaces %>
+ <% if white_ip.ipv4.present? %> + <%= link_to(white_ip.ipv4, [:admin, registrar, white_ip]) %> + <% end %> + + <% if white_ip.ipv6.present? %> + <%= link_to(white_ip.ipv6, [:admin, registrar, white_ip]) %> + <% end %> + <%= white_ip.interfaces.join(', ').upcase %>
+ + +
diff --git a/app/views/admin/registrars/index.html.erb b/app/views/admin/registrars/index.html.erb index 49bf7eae8..a66816568 100644 --- a/app/views/admin/registrars/index.html.erb +++ b/app/views/admin/registrars/index.html.erb @@ -20,10 +20,10 @@ <%= sort_link(@q, 'name') %> - <%= sort_link(@q, 'reg_no', t(:reg_no)) %> + <%= sort_link(@q, 'reg_no', Registrar.human_attribute_name(:reg_no)) %> - <%= t(:credit_balance) %> + <%= Registrar.human_attribute_name :balance %> <%= t(:test_registrar) %> diff --git a/app/views/admin/registrars/show.html.erb b/app/views/admin/registrars/show.html.erb index ebf4ec179..65435ef77 100644 --- a/app/views/admin/registrars/show.html.erb +++ b/app/views/admin/registrars/show.html.erb @@ -26,198 +26,25 @@ -<% if @registrar.errors.any? %> - <% @registrar.errors.each do |attr, err| %> - <%= err %> -
- <% end %> -<% end %> -<% if @registrar.errors.any? %> -
-<% end %>
-
-
-

- <%= t(:general) %> -

-
-
-
-
- <%= t(:name) %> -
-
- <%= @registrar.name %> -
-
- <%= t(:reg_no) %> -
-
- <%= @registrar.reg_no %> -
-
- <%= t(:reference_no) %> -
-
- <%= @registrar.reference_no %> -
-
- <%= t(:id) %> -
-
- <%= @registrar.code %> -
-
- <%= t(:credit_balance) %> -
-
- <%= @registrar.balance %> -
-
- <%= Registrar.human_attribute_name :website %> -
-
- <%= @registrar.website %> -
-
-
-
+ <%= render 'details', registrar: @registrar %>
-
-
-

- <%= t(:contact) %> -

-
-
-
-
- <%= t(:country) %> -
-
- <%= @registrar.country %> -
-
- <%= t(:address) %> -
-
- <%= @registrar.address %> -
-
- <%= t(:contact_phone) %> -
-
- <%= @registrar.phone %> -
-
- <%= t(:contact_email) %> -
-
- <%= @registrar.email %> -
-
- <%= t(:billing_email) %> -
-
- <%= @registrar.billing_email %> -
-
-
-
+ <%= render 'contacts', registrar: @registrar %> <%= render 'billing', registrar: @registrar %> - <%= render 'admin/registrars/show/preferences', registrar: registrar %> + <%= render 'preferences', registrar: registrar %>
+
-
-
-
- <%= t('.api_users') %> -
-
- <%= link_to(t('.new_api_use_btn'), new_admin_registrar_api_user_path(@registrar), class: 'btn btn-default btn-xs') %> -
-
-
- - - - - - - - - <% @registrar.api_users.each do |x| %> - - - - - <% end %> - -
- <%= t(:username) %> - - <%= t('.active') %> -
- <%= link_to(x, [:admin, x]) %> - - <%= x.active %> -
-
-
+ <%= render 'users', registrar: @registrar %>
+
-
-
-
- <%= t(:white_ips) %> -
-
- <%= link_to(t(:create_new_white_ip), new_admin_registrar_white_ip_path(@registrar), class: 'btn btn-default btn-xs') %> -
-
-
- - - - - - - - - - <% @registrar.white_ips.each do |x| %> - - - - - - <% end %> - -
- <%= t(:ipv4) %> - - <%= t(:ipv6) %> - - <%= t(:interfaces) %> -
- <% if x.ipv4.present? %> - <%= link_to(x.ipv4, [:admin, @registrar, x]) %> - <% end %> - - <% if x.ipv6.present? %> - <%= link_to(x.ipv6, [:admin, @registrar, x]) %> - <% end %> - - <%= x.interfaces.join(', ').upcase %> -
-
-
+ <%= render 'white_ips', registrar: @registrar %>
diff --git a/app/views/admin/white_ips/new.haml b/app/views/admin/white_ips/new.haml index 99150a871..220599d2a 100644 --- a/app/views/admin/white_ips/new.haml +++ b/app/views/admin/white_ips/new.haml @@ -1,5 +1,5 @@ - content_for :actions do = link_to(t(:back_to_registrar), admin_registrar_path(@registrar), class: 'btn btn-default') -= render 'shared/title', name: t(:create_new_white_ip) += render 'shared/title', name: t('.header') = render 'form' diff --git a/app/views/admin/white_ips/show.haml b/app/views/admin/white_ips/show.haml index 33688d9fe..2ec354aa4 100644 --- a/app/views/admin/white_ips/show.haml +++ b/app/views/admin/white_ips/show.haml @@ -14,11 +14,11 @@ %dt= t(:registrar_name) %dd= link_to(@registrar, [:admin, @registrar]) - %dt= t(:ipv4) + %dt= WhiteIp.human_attribute_name :ipv4 %dd= @white_ip.ipv4 - %dt= t(:ipv6) + %dt= WhiteIp.human_attribute_name :ipv6 %dd= @white_ip.ipv6 - %dt= t(:interfaces) + %dt= WhiteIp.human_attribute_name :interfaces %dd= @white_ip.interfaces.join(', ').upcase diff --git a/app/views/registrant/registrars/index.haml b/app/views/registrant/registrars/index.haml index 0489bcf52..03bd5a02a 100644 --- a/app/views/registrant/registrars/index.haml +++ b/app/views/registrant/registrars/index.haml @@ -10,7 +10,7 @@ %th{class: 'col-xs-6'} = sort_link(@q, 'name') %th{class: 'col-xs-6'} - = sort_link(@q, 'reg_no', t(:reg_no)) + = sort_link(@q, 'reg_no', Registrar.human_attribute_name(:reg_no)) %tbody - @registrars.each do |x| %tr diff --git a/app/views/registrant/registrars/show.haml b/app/views/registrant/registrars/show.haml index 6d4aa9e79..678e387de 100644 --- a/app/views/registrant/registrars/show.haml +++ b/app/views/registrant/registrars/show.haml @@ -16,7 +16,7 @@ %dt= t(:name) %dd= @registrar.name - %dt= t(:reg_no) + %dt= Registrar.human_attribute_name :reg_no %dd= @registrar.reg_no %dt= Registrar.human_attribute_name :vat_no diff --git a/app/views/registrar/invoices/partials/_details.haml b/app/views/registrar/invoices/partials/_details.haml index 1375c76f8..69248b457 100644 --- a/app/views/registrar/invoices/partials/_details.haml +++ b/app/views/registrar/invoices/partials/_details.haml @@ -32,5 +32,5 @@ %dt= t(:description) %dd=@invoice.description - %dt= t(:reference_no) + %dt= Invoice.human_attribute_name :reference_no %dd= @invoice.reference_no diff --git a/app/views/registrar/invoices/partials/_seller.haml b/app/views/registrar/invoices/partials/_seller.haml index 9c5387e16..30f27bcef 100644 --- a/app/views/registrar/invoices/partials/_seller.haml +++ b/app/views/registrar/invoices/partials/_seller.haml @@ -4,7 +4,7 @@ %dt= t(:name) %dd= @invoice.seller_name - %dt= t(:reg_no) + %dt= Registrar.human_attribute_name :reg_no %dd= @invoice.seller_reg_no %dt= t(:iban) diff --git a/app/views/registrar/invoices/pdf.haml b/app/views/registrar/invoices/pdf.haml index 4f3b499df..3d6e111ef 100644 --- a/app/views/registrar/invoices/pdf.haml +++ b/app/views/registrar/invoices/pdf.haml @@ -182,7 +182,7 @@ %dt= t(:description) %dd=@invoice.description - %dt= t(:reference_no) + %dt= Invoice.human_attribute_name :reference_no %dd= @invoice.reference_no .col-md-6.right diff --git a/app/views/registrar/registrar_nameservers/_form.html.erb b/app/views/registrar/registrar_nameservers/_form.html.erb index cb872a91a..3aca3e0e1 100644 --- a/app/views/registrar/registrar_nameservers/_form.html.erb +++ b/app/views/registrar/registrar_nameservers/_form.html.erb @@ -7,7 +7,6 @@
<%= text_field_tag :old_hostname, params[:old_hostname], autofocus: true, required: true, - spellcheck: false, class: 'form-control' %>
@@ -19,7 +18,6 @@
<%= text_field_tag :new_hostname, params[:new_hostname], required: true, - spellcheck: false, class: 'form-control' %>
@@ -30,7 +28,7 @@
- <%= text_area_tag :ipv4, params[:ipv4], spellcheck: false, class: 'form-control' %> + <%= text_area_tag :ipv4, params[:ipv4], class: 'form-control' %>
@@ -40,7 +38,7 @@
- <%= text_area_tag :ipv6, params[:ipv6], spellcheck: false, class: 'form-control' %> + <%= text_area_tag :ipv6, params[:ipv6], class: 'form-control' %> <%= t '.ip_hint' %>
diff --git a/config/locales/admin/registrars.en.yml b/config/locales/admin/registrars.en.yml index 5d212f219..3586960b0 100644 --- a/config/locales/admin/registrars.en.yml +++ b/config/locales/admin/registrars.en.yml @@ -12,12 +12,12 @@ en: edit_btn: Edit delete_btn: Delete delete_btn_confirm: Are you sure you want delete registrar? - new_api_use_btn: New API user - active: Active - api_users: API users - preferences: - header: Preferences + edit: + header: Edit registrar + + billing: + header: Billing edit: header: Edit registrar @@ -44,3 +44,20 @@ en: 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 diff --git a/config/locales/admin/white_ips.en.yml b/config/locales/admin/white_ips.en.yml new file mode 100644 index 000000000..b42db4cff --- /dev/null +++ b/config/locales/admin/white_ips.en.yml @@ -0,0 +1,5 @@ +en: + admin: + white_ips: + new: + header: New whitelisted IP diff --git a/config/locales/en.yml b/config/locales/en.yml index 2ca4a207b..24d515268 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -202,9 +202,6 @@ en: state: 'State / Province' deposit: amount: 'Amount' - white_ip: - ipv4: 'IPv4' - ipv6: 'IPv6' errors: messages: @@ -301,7 +298,6 @@ en: reg_no: 'Reg. no' status: 'Status' contact: 'Contact' - credit_balance: 'Credit balance' starting_balance: 'Starting balance' destroyed: 'Destroyed' @@ -386,7 +382,6 @@ en: choose: 'Choose...' created_before: 'Created before' created_after: 'Created after' - billing_email: 'Billing e-mail' contact_phone: 'Contact phone' contact_email: 'Contact e-mail' address_help: 'Street name, house no - apartment no, city, county, country, zip' @@ -575,7 +570,6 @@ en: queried_at: 'Queried at' import_file_path: 'Import file path' bank_code: 'Bank code' - reference_no: 'Reference no' currency: 'Currency' buyer_name: 'Buyer name' buyer_iban: 'Buyer IBAN' @@ -652,8 +646,6 @@ en: not_valid_domain_verification_body: This could mean your verification has been expired or done already.

Please contact us if you think something is wrong. upload_crt: 'Upload CRT' crt_or_csr_must_be_present: 'CRT or CSR must be present' - white_ips: 'White IP-s' - create_new_white_ip: 'Create new white IP' ipv4_or_ipv6_must_be_present: 'IPv4 or IPv6 must be present' white_ip: 'White IP' edit_white_ip: 'Edit white IP' @@ -741,7 +733,6 @@ en: failure: "It was not saved" contact_is_not_valid: 'Contact %{value} is not valid, please fix the invalid contact' welcome_to_eis_registrar_portal: 'Welcome to EIS Registrar portal' - interfaces: 'Interfaces' next: 'Next' previous: 'Previous' personal_domain_verification_url: 'Personal domain verification url' @@ -771,3 +762,5 @@ en: attributes: vat_no: VAT number vat_rate: VAT rate + ipv4: IPv4 + ipv6: IPv6 diff --git a/config/routes.rb b/config/routes.rb index 77f856c8f..9caeef4a2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -97,7 +97,6 @@ Rails.application.routes.draw do get 'pay/go/:bank' => 'payments#pay', as: 'payment_with' end - # REGISTRANT ROUTES namespace :registrant do root 'domains#index' @@ -111,17 +110,6 @@ Rails.application.routes.draw do end end - # resources :invoices do - # member do - # get 'download_pdf' - # match 'forward', via: [:post, :get] - # patch 'cancel' - # end - # end - - # resources :deposits - # resources :account_activities - resources :domain_update_confirms resources :domain_delete_confirms @@ -150,8 +138,6 @@ Rails.application.routes.draw do end resources :registrars do - resources :api_users - resources :white_ips collection do get :search end diff --git a/db/migrate/20180309053424_add_registrars_unique_constraints.rb b/db/migrate/20180309053424_add_registrars_unique_constraints.rb index 1c2d3c1b8..fb3455896 100644 --- a/db/migrate/20180309053424_add_registrars_unique_constraints.rb +++ b/db/migrate/20180309053424_add_registrars_unique_constraints.rb @@ -2,7 +2,6 @@ class AddRegistrarsUniqueConstraints < ActiveRecord::Migration def up execute <<-SQL ALTER TABLE registrars ADD CONSTRAINT unique_name UNIQUE (name); - ALTER TABLE registrars ADD CONSTRAINT unique_reg_no UNIQUE (reg_no); ALTER TABLE registrars ADD CONSTRAINT unique_reference_no UNIQUE (reference_no); ALTER TABLE registrars ADD CONSTRAINT unique_code UNIQUE (code); SQL @@ -11,7 +10,6 @@ class AddRegistrarsUniqueConstraints < ActiveRecord::Migration def down execute <<-SQL ALTER TABLE registrars DROP CONSTRAINT unique_name; - ALTER TABLE registrars DROP CONSTRAINT unique_reg_no; ALTER TABLE registrars DROP CONSTRAINT unique_reference_no; ALTER TABLE registrars DROP CONSTRAINT unique_code; SQL diff --git a/db/structure.sql b/db/structure.sql index 96a9637fe..7a48a2a7b 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -3244,7 +3244,7 @@ ALTER TABLE ONLY settings -- --- Name: unique_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: unique_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY registrars @@ -3260,7 +3260,7 @@ ALTER TABLE ONLY contacts -- --- Name: unique_name; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: unique_name; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY registrars @@ -3268,7 +3268,7 @@ ALTER TABLE ONLY registrars -- --- Name: unique_reference_no; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: unique_reference_no; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY registrars @@ -3276,7 +3276,7 @@ ALTER TABLE ONLY registrars -- --- Name: unique_reg_no; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: unique_reg_no; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY registrars diff --git a/doc/controllers_complete.svg b/doc/controllers_complete.svg index 765d4a08b..dcf736019 100644 --- a/doc/controllers_complete.svg +++ b/doc/controllers_complete.svg @@ -492,7 +492,6 @@ _layout -check_ip role_base_root_url diff --git a/test/fixtures/registrars.yml b/test/fixtures/registrars.yml index e54d79fad..6ff6d2dc9 100644 --- a/test/fixtures/registrars.yml +++ b/test/fixtures/registrars.yml @@ -41,3 +41,12 @@ complete: language: en vat_no: US12345 vat_rate: 0.05 + +not_in_use: + name: any + reg_no: any + code: any + email: any@example.com + country_code: US + accounting_customer_code: any + language: en diff --git a/test/integration/admin/registrars/delete_test.rb b/test/integration/admin/registrars/delete_test.rb index 22e561664..34eb142bf 100644 --- a/test/integration/admin/registrars/delete_test.rb +++ b/test/integration/admin/registrars/delete_test.rb @@ -5,7 +5,7 @@ class AdminAreaDeleteRegistrarTest < ActionDispatch::IntegrationTest login_as users(:admin) end - def test_can_be_deleted_if_not_in_use + def test_can_be_deleted_when_not_in_use visit admin_registrar_url(registrars(:not_in_use)) assert_difference 'Registrar.count', -1 do @@ -15,4 +15,16 @@ class AdminAreaDeleteRegistrarTest < ActionDispatch::IntegrationTest 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 diff --git a/test/integration/admin/registrars/new_test.rb b/test/integration/admin/registrars/new_test.rb index 88ff76288..61a7a43be 100644 --- a/test/integration/admin/registrars/new_test.rb +++ b/test/integration/admin/registrars/new_test.rb @@ -9,10 +9,9 @@ class AdminAreaNewRegistrarTest < ActionDispatch::IntegrationTest visit admin_registrars_url click_link_or_button 'New registrar' - fill_in 'Name', with: 'Brand new name' + 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' diff --git a/test/models/registrar_test.rb b/test/models/registrar_test.rb index 12d5be633..dc2f31ffa 100644 --- a/test/models/registrar_test.rb +++ b/test/models/registrar_test.rb @@ -24,13 +24,13 @@ class RegistrarTest < ActiveSupport::TestCase assert @registrar.invalid? end - def test_rejects_absent_accounting_customer_code - @registrar.accounting_customer_code = nil + def test_invalid_without_accounting_customer_code + @registrar.accounting_customer_code = '' assert @registrar.invalid? end def test_invalid_without_country_code - @registrar.country_code = nil + @registrar.country_code = '' assert @registrar.invalid? end