From 7a890fccd2fa290e820f3c7416e0d06e94d4d326 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 2 Mar 2017 21:41:17 +0200 Subject: [PATCH 01/14] Remove unused contact disclose partials from registrar area #270 --- .../contacts/form_partials/_disclose.haml | 41 ------------------- .../contacts/partials/_disclose.haml | 10 ----- 2 files changed, 51 deletions(-) delete mode 100644 app/views/registrar/contacts/form_partials/_disclose.haml delete mode 100644 app/views/registrar/contacts/partials/_disclose.haml diff --git a/app/views/registrar/contacts/form_partials/_disclose.haml b/app/views/registrar/contacts/form_partials/_disclose.haml deleted file mode 100644 index 51f675c577..0000000000 --- a/app/views/registrar/contacts/form_partials/_disclose.haml +++ /dev/null @@ -1,41 +0,0 @@ -.panel.panel-default - .panel-heading.clearfix - .pull-left= t(:contact_disclosure) - - .panel-body - .form-group - = label_tag :contact_disclose_flag, t(:flag_type), class: 'col-md-2 control-label' - .col-md-10 - =# check_box_tag('contact[disclose][sv_policy]', @contact_params[:disclose][:sv_policy], class: 'form-control') - = select_tag('contact[disclose][flag]', options_for_select(Depp::Contact::DISCLOSURE_TYPES) ) - - .panel-body - .form-group - = label_tag :contact_disclose_name, t(:name), class: 'col-md-2 control-label' - .col-md-10 - = check_box_tag('contact[disclose][name]') - - .form-group - = label_tag :contact_disclose_email, t(:email), class: 'col-md-2 control-label' - .col-md-10 - = check_box_tag('contact[disclose][email]') - - .form-group - = label_tag :contact_disclose_org_name, t(:org_name), class: 'col-md-2 control-label' - .col-md-10 - = check_box_tag('contact[disclose][org_name]') - - .form-group - = label_tag :contact_disclose_address, t(:address), class: 'col-md-2 control-label' - .col-md-10 - = check_box_tag('contact[disclose][address]') - - .form-group - = label_tag :contact_disclose_voice, t(:voice), class: 'col-md-2 control-label' - .col-md-10 - = check_box_tag('contact[disclose][voice]') - - .form-group - = label_tag :contact_disclose_fax, t(:fax), class: 'col-md-2 control-label' - .col-md-10 - = check_box_tag('contact[disclose][fax]') diff --git a/app/views/registrar/contacts/partials/_disclose.haml b/app/views/registrar/contacts/partials/_disclose.haml deleted file mode 100644 index 734ca056d6..0000000000 --- a/app/views/registrar/contacts/partials/_disclose.haml +++ /dev/null @@ -1,10 +0,0 @@ -- @contact[:disclose].each do |flag, data| - - next if data.empty? - .panel.panel-default - .panel-heading - %h3.panel-title= t("disclosure-#{flag}") - .panel-body - %dl.dl-horizontal - - data.each do |k,v| - %dt= t(k) - From dbbf64dd6faba8a487146a5d7f1feaaecd08af2f Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 2 Mar 2017 21:43:39 +0200 Subject: [PATCH 02/14] Refactor registrar area contact form #270 --- app/views/registrar/contacts/_form.haml | 8 ++++---- spec/views/registrar/contacts/_form.haml_spec.rb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/registrar/contacts/_form.haml b/app/views/registrar/contacts/_form.haml index f826d06770..cf8217e13b 100644 --- a/app/views/registrar/contacts/_form.haml +++ b/app/views/registrar/contacts/_form.haml @@ -3,20 +3,20 @@ = f.hidden_field :password .row .col-md-8 - = render 'registrar/contacts/form_partials/general', f: f + = render 'registrar/contacts/form/general', f: f - if address_processing? .row .col-md-8 - = render 'registrar/contacts/form_partials/address', f: f + = render 'registrar/contacts/form/address', f: f - if !@contact.persisted? .row .col-md-8 - = render 'registrar/contacts/form_partials/code', f: f + = render 'registrar/contacts/form/code', f: f .row .col-md-8 - = render 'registrar/contacts/form_partials/legal_document', f: f + = render 'registrar/contacts/form/legal_document', f: f .row .col-md-8.text-right diff --git a/spec/views/registrar/contacts/_form.haml_spec.rb b/spec/views/registrar/contacts/_form.haml_spec.rb index 307c495e82..b1ecdf0cf3 100644 --- a/spec/views/registrar/contacts/_form.haml_spec.rb +++ b/spec/views/registrar/contacts/_form.haml_spec.rb @@ -8,10 +8,10 @@ assign(:contact, contact) stub_template 'registrar/shared/_error_messages' => '' - stub_template 'registrar/contacts/form_partials/_general' => '' - stub_template 'registrar/contacts/form_partials/_address' => 'address info' - stub_template 'registrar/contacts/form_partials/_code' => '' - stub_template 'registrar/contacts/form_partials/_legal_document' => '' + stub_template 'registrar/contacts/form/_general' => '' + stub_template 'registrar/contacts/form/_address' => 'address info' + stub_template 'registrar/contacts/form/_code' => '' + stub_template 'registrar/contacts/form/_legal_document' => '' end context 'when address processing is enabled' do From 0f7ba265005de6523710d3922a2ed068ea8adaf0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 2 Mar 2017 21:45:04 +0200 Subject: [PATCH 03/14] Refactor registrar area contact form #270 --- .../registrar/contacts/{form_partials => form}/_address.haml | 0 app/views/registrar/contacts/{form_partials => form}/_code.haml | 0 .../registrar/contacts/{form_partials => form}/_general.haml | 0 .../contacts/{form_partials => form}/_legal_document.haml | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename app/views/registrar/contacts/{form_partials => form}/_address.haml (100%) rename app/views/registrar/contacts/{form_partials => form}/_code.haml (100%) rename app/views/registrar/contacts/{form_partials => form}/_general.haml (100%) rename app/views/registrar/contacts/{form_partials => form}/_legal_document.haml (100%) diff --git a/app/views/registrar/contacts/form_partials/_address.haml b/app/views/registrar/contacts/form/_address.haml similarity index 100% rename from app/views/registrar/contacts/form_partials/_address.haml rename to app/views/registrar/contacts/form/_address.haml diff --git a/app/views/registrar/contacts/form_partials/_code.haml b/app/views/registrar/contacts/form/_code.haml similarity index 100% rename from app/views/registrar/contacts/form_partials/_code.haml rename to app/views/registrar/contacts/form/_code.haml diff --git a/app/views/registrar/contacts/form_partials/_general.haml b/app/views/registrar/contacts/form/_general.haml similarity index 100% rename from app/views/registrar/contacts/form_partials/_general.haml rename to app/views/registrar/contacts/form/_general.haml diff --git a/app/views/registrar/contacts/form_partials/_legal_document.haml b/app/views/registrar/contacts/form/_legal_document.haml similarity index 100% rename from app/views/registrar/contacts/form_partials/_legal_document.haml rename to app/views/registrar/contacts/form/_legal_document.haml From 9b52adae3c65336362a118c8ffd4818b30ee2404 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 2 Mar 2017 23:11:56 +0200 Subject: [PATCH 04/14] Refactor registrar area contact form #270 --- app/views/registrar/contacts/delete.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/registrar/contacts/delete.haml b/app/views/registrar/contacts/delete.haml index 857c57cf8c..8662b738c8 100644 --- a/app/views/registrar/contacts/delete.haml +++ b/app/views/registrar/contacts/delete.haml @@ -10,7 +10,7 @@ .row .col-md-8 - = render 'registrar/contacts/form_partials/legal_document', f: f + = render 'registrar/contacts/form/legal_document', f: f %hr .row From 275c2f388b9d51909c4bf71f46f910af663c7545 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 2 Mar 2017 23:13:40 +0200 Subject: [PATCH 05/14] Refactor registrar area domain form #270 --- app/views/registrar/domains/_form.haml | 8 ++++---- .../domains/{form_partials => form}/_contacts.haml | 0 .../domains/{form_partials => form}/_dnskeys.haml | 0 .../domains/{form_partials => form}/_general.haml | 0 .../domains/{form_partials => form}/_nameservers.haml | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename app/views/registrar/domains/{form_partials => form}/_contacts.haml (100%) rename app/views/registrar/domains/{form_partials => form}/_dnskeys.haml (100%) rename app/views/registrar/domains/{form_partials => form}/_general.haml (100%) rename app/views/registrar/domains/{form_partials => form}/_nameservers.haml (100%) diff --git a/app/views/registrar/domains/_form.haml b/app/views/registrar/domains/_form.haml index 83ad8add0f..0e075acdf6 100644 --- a/app/views/registrar/domains/_form.haml +++ b/app/views/registrar/domains/_form.haml @@ -3,10 +3,10 @@ .row .col-md-8 #general-tab.tab-pane.active - = render 'registrar/domains/form_partials/general' - = render 'registrar/domains/form_partials/contacts' - = render 'registrar/domains/form_partials/nameservers' - = render 'registrar/domains/form_partials/dnskeys' + = render 'registrar/domains/form/general' + = render 'registrar/domains/form/contacts' + = render 'registrar/domains/form/nameservers' + = render 'registrar/domains/form/dnskeys' .panel.panel-default .panel-heading.clearfix diff --git a/app/views/registrar/domains/form_partials/_contacts.haml b/app/views/registrar/domains/form/_contacts.haml similarity index 100% rename from app/views/registrar/domains/form_partials/_contacts.haml rename to app/views/registrar/domains/form/_contacts.haml diff --git a/app/views/registrar/domains/form_partials/_dnskeys.haml b/app/views/registrar/domains/form/_dnskeys.haml similarity index 100% rename from app/views/registrar/domains/form_partials/_dnskeys.haml rename to app/views/registrar/domains/form/_dnskeys.haml diff --git a/app/views/registrar/domains/form_partials/_general.haml b/app/views/registrar/domains/form/_general.haml similarity index 100% rename from app/views/registrar/domains/form_partials/_general.haml rename to app/views/registrar/domains/form/_general.haml diff --git a/app/views/registrar/domains/form_partials/_nameservers.haml b/app/views/registrar/domains/form/_nameservers.haml similarity index 100% rename from app/views/registrar/domains/form_partials/_nameservers.haml rename to app/views/registrar/domains/form/_nameservers.haml From 19a107a4eedddc17a2bb59e9aaaf38e3134cd2d2 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 2 Mar 2017 23:23:32 +0200 Subject: [PATCH 06/14] Add missing translations #270 --- app/views/registrar/domains/_form.haml | 2 +- app/views/registrar/domains/form/_dnskeys.haml | 4 ++-- config/locales/registrar/domains.en.yml | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/views/registrar/domains/_form.haml b/app/views/registrar/domains/_form.haml index 0e075acdf6..a1a717a9bd 100644 --- a/app/views/registrar/domains/_form.haml +++ b/app/views/registrar/domains/_form.haml @@ -26,7 +26,7 @@ .row .col-md-8.text-right - = button_tag(t('shared.save'), class: 'btn btn-warning') + = button_tag(t('.save_btn'), class: 'btn btn-warning') :javascript $(function () { diff --git a/app/views/registrar/domains/form/_dnskeys.haml b/app/views/registrar/domains/form/_dnskeys.haml index 818ea67a2c..7d41682f6f 100644 --- a/app/views/registrar/domains/form/_dnskeys.haml +++ b/app/views/registrar/domains/form/_dnskeys.haml @@ -39,7 +39,7 @@ .form-group .col-md-3.control-label - = label_tag "domain_dnskeys_attributes_#{k}_flags", t(:flags) + = label_tag "domain_dnskeys_attributes_#{k}_flags", t('.flags') .col-md-7 = select_tag "domain[dnskeys_attributes][#{k}][flags]", options_for_select(Depp::Dnskey::FLAGS, v['flags']), @@ -55,7 +55,7 @@ .form-group .col-md-3.control-label - = label_tag "domain_dnskeys_attributes_#{k}_alg", t(:alg) + = label_tag "domain_dnskeys_attributes_#{k}_alg", t('.alg') .col-md-7 = select_tag "domain[dnskeys_attributes][#{k}][alg]", options_for_select(Depp::Dnskey::ALGORITHMS, v['alg']), { class: 'form-control' } diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index cdef2bd5ab..6cf0536c51 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -8,3 +8,9 @@ en: registrant_name: Registrant name registrant_code: Registrant code expire_time: Date of expiry + + form: + save_btn: Save + dnskeys: + flags: Flags + alg: Algorithm From e3a92ab02ea2d0f07e7152d16735c461855e4318 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 2 Mar 2017 23:32:07 +0200 Subject: [PATCH 07/14] Remove obsolete js #270 --- app/views/registrar/domains/_form.haml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/views/registrar/domains/_form.haml b/app/views/registrar/domains/_form.haml index a1a717a9bd..b58fa0bb6a 100644 --- a/app/views/registrar/domains/_form.haml +++ b/app/views/registrar/domains/_form.haml @@ -27,8 +27,3 @@ .row .col-md-8.text-right = button_tag(t('.save_btn'), class: 'btn btn-warning') - -:javascript - $(function () { - $('#tabs a:first').tab('show') - }) From 41cf098e8c22c656a8c35cc11cc882b9b2c377e2 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 3 Mar 2017 01:43:41 +0200 Subject: [PATCH 08/14] Add missing translations #270 --- app/views/registrar/domains/partials/_general.haml | 6 +++--- config/locales/registrar/domains.en.yml | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/views/registrar/domains/partials/_general.haml b/app/views/registrar/domains/partials/_general.haml index 0f1a2a831b..ca3dd99924 100644 --- a/app/views/registrar/domains/partials/_general.haml +++ b/app/views/registrar/domains/partials/_general.haml @@ -14,14 +14,14 @@ %dt= t(:registrant) %dd= "#{registrant.name} (#{@data.css('registrant').text})" - %dt= t(:registered) + %dt= t('.registered') %dd= @data.css('crDate').text %dt= t(:valid_to) %dd= @data.css('exDate').text - %dt= t(:created) + %dt= t('.created') %dd= @data.css('crDate').text - %dt= t(:updated) + %dt= t('.updated') %dd= @data.css('upDate').text diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index 6cf0536c51..287704d29b 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -14,3 +14,9 @@ en: dnskeys: flags: Flags alg: Algorithm + + partials: + general: + registered: Registered + created: Created + updated: Updated From 53de03bd2efae9785ebcc31057ab9254a951bb00 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 5 Mar 2017 18:35:02 +0200 Subject: [PATCH 09/14] Add default form builder --- app/helpers/application_helper.rb | 5 +++++ app/helpers/default_form_builder.rb | 6 ++++++ app/helpers/form_helper.rb | 8 ++++++++ app/helpers/form_tag_helper.rb | 8 ++++++++ config/application.rb | 2 ++ 5 files changed, 29 insertions(+) create mode 100644 app/helpers/default_form_builder.rb create mode 100644 app/helpers/form_helper.rb create mode 100644 app/helpers/form_tag_helper.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index feb2a76774..7e2e2d5352 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -83,4 +83,9 @@ def changing_css_class(version, *attrs) version.object_changes.to_h.slice(*attrs).any? && css_class end end + + def legal_document_types + types = LegalDocument::TYPES.dup + ".#{types.join(',.')}" + end end diff --git a/app/helpers/default_form_builder.rb b/app/helpers/default_form_builder.rb new file mode 100644 index 0000000000..7353171981 --- /dev/null +++ b/app/helpers/default_form_builder.rb @@ -0,0 +1,6 @@ +class DefaultFormBuilder < ActionView::Helpers::FormBuilder + def legal_document_field(method, options = {}) + self.multipart = true + @template.legal_document_field(@object_name, method, objectify_options(options)) + end +end diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb new file mode 100644 index 0000000000..a3a139e095 --- /dev/null +++ b/app/helpers/form_helper.rb @@ -0,0 +1,8 @@ +module FormHelper + def legal_document_field(object_name, method, options = {}) + options[:data] = { legal_document: true } + options[:accept] = legal_document_types unless options[:accept] + + file_field(object_name, method, options) + end +end diff --git a/app/helpers/form_tag_helper.rb b/app/helpers/form_tag_helper.rb new file mode 100644 index 0000000000..d19a59db52 --- /dev/null +++ b/app/helpers/form_tag_helper.rb @@ -0,0 +1,8 @@ +module FormTagHelper + def legal_document_field_tag(name, options = {}) + options[:data] = { legal_document: true } + options[:accept] = legal_document_types unless options[:accept] + + file_field_tag(name, options) + end +end diff --git a/config/application.rb b/config/application.rb index 109fa4d1ba..e946f5d115 100644 --- a/config/application.rb +++ b/config/application.rb @@ -78,6 +78,8 @@ class Application < Rails::Application domain: ENV['smtp_domain'], openssl_verify_mode: ENV['smtp_openssl_verify_mode'] } + + config.action_view.default_form_builder = 'DefaultFormBuilder' end end From 2983a0e3310d5360ad6d4fcd6ee56a8e4c7355f3 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 5 Mar 2017 18:40:43 +0200 Subject: [PATCH 10/14] Allow api_user_with_unlimited_balance factory to accept registrar --- spec/factories/api_user.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/factories/api_user.rb b/spec/factories/api_user.rb index 01c2c70e05..a38fb8bf96 100644 --- a/spec/factories/api_user.rb +++ b/spec/factories/api_user.rb @@ -10,8 +10,13 @@ end factory :api_user_with_unlimited_balance do - after :build do |api_user| - api_user.registrar = create(:registrar_with_unlimited_balance) + transient do + registrar false + end + + after :build do |api_user, evaluator| + registrar = (evaluator.registrar || create(:registrar_with_unlimited_balance)) + api_user.registrar = registrar end end end From 8a5d06827c7a8264a623666bd9c4cf29dc223e03 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 5 Mar 2017 18:42:47 +0200 Subject: [PATCH 11/14] Add missing translations #270 --- app/views/registrar/contacts/partials/_domains.haml | 2 +- config/locales/registrar/contacts.en.yml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 config/locales/registrar/contacts.en.yml diff --git a/app/views/registrar/contacts/partials/_domains.haml b/app/views/registrar/contacts/partials/_domains.haml index f580195672..d2943e8ef1 100644 --- a/app/views/registrar/contacts/partials/_domains.haml +++ b/app/views/registrar/contacts/partials/_domains.haml @@ -18,7 +18,7 @@ %th{class: 'col-xs-3'}=custom_sort_link t(:domain_name), :name %th{class: 'col-xs-3'}=custom_sort_link t(:registrar_name), :registrar_name %th{class: 'col-xs-3'}=custom_sort_link t(:valid_to), :valid_to - %th{class: 'col-xs-3'}= t(:roles) + %th{class: 'col-xs-3'}= t('.roles') %tbody - domains.each do |x| %tr diff --git a/config/locales/registrar/contacts.en.yml b/config/locales/registrar/contacts.en.yml new file mode 100644 index 0000000000..2a3f5ba3e2 --- /dev/null +++ b/config/locales/registrar/contacts.en.yml @@ -0,0 +1,6 @@ +en: + registrar: + contacts: + partials: + domains: + roles: Roles From b4bbb17bff54b95c66471e6ca9dd2dd604147533 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 5 Mar 2017 18:54:26 +0200 Subject: [PATCH 12/14] Use legal_document_field instead of file_field in registrar area #270 --- .../contacts/form/_legal_document.haml | 2 +- app/views/registrar/domains/_form.haml | 2 +- .../form/_legal_document.haml_spec.rb | 15 ++++++++++++++ .../registrar/domains/_form.haml_spec.rb | 20 +++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 spec/views/registrar/contacts/form/_legal_document.haml_spec.rb create mode 100644 spec/views/registrar/domains/_form.haml_spec.rb diff --git a/app/views/registrar/contacts/form/_legal_document.haml b/app/views/registrar/contacts/form/_legal_document.haml index bffa698311..6507da1d90 100644 --- a/app/views/registrar/contacts/form/_legal_document.haml +++ b/app/views/registrar/contacts/form/_legal_document.haml @@ -10,4 +10,4 @@ = f.label :legal_document, t(:legal_document) %p.help-block= t(:legal_document_max_size) .col-md-7 - = f.file_field :legal_document, :value => '', data: {legal_document: true} + = f.legal_document_field :legal_document diff --git a/app/views/registrar/domains/_form.haml b/app/views/registrar/domains/_form.haml index b58fa0bb6a..d6428233b8 100644 --- a/app/views/registrar/domains/_form.haml +++ b/app/views/registrar/domains/_form.haml @@ -18,7 +18,7 @@ = label_tag 'domain[legal_document]', t(:legal_document), class: c %p.help-block= t(:legal_document_max_size) .col-md-7 - = file_field_tag 'domain[legal_document]', required: fr, data: {legal_document: true} + = legal_document_field_tag 'domain[legal_document]', required: fr .col-md-4 %p.domain-general-help= t(:domain_general_help).html_safe %p.domain-admin-contact-help= t(:domain_admin_contact_help).html_safe diff --git a/spec/views/registrar/contacts/form/_legal_document.haml_spec.rb b/spec/views/registrar/contacts/form/_legal_document.haml_spec.rb new file mode 100644 index 0000000000..b5f428ca13 --- /dev/null +++ b/spec/views/registrar/contacts/form/_legal_document.haml_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +RSpec.describe 'registrar/contacts/form/_legal_document' do + let(:contact) { instance_spy(Depp::Contact) } + + before :example do + allow(view).to receive(:f).and_return(DefaultFormBuilder.new(:depp_contact, contact, view, {})) + assign(:contact, contact) + end + + it 'has legal document' do + render + expect(rendered).to have_css('[name="depp_contact[legal_document]"]') + end +end diff --git a/spec/views/registrar/domains/_form.haml_spec.rb b/spec/views/registrar/domains/_form.haml_spec.rb new file mode 100644 index 0000000000..b7833f92af --- /dev/null +++ b/spec/views/registrar/domains/_form.haml_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' + +RSpec.describe 'registrar/domains/_form' do + let(:domain) { instance_spy(Depp::Domain) } + + before :example do + allow(view).to receive(:f).and_return(DefaultFormBuilder.new(:domain, domain, view, {})) + assign(:domain, domain) + + stub_template 'registrar/domains/form/_general' => '' + stub_template 'registrar/domains/form/_contacts' => '' + stub_template 'registrar/domains/form/_nameservers' => '' + stub_template 'registrar/domains/form/_dnskeys' => '' + end + + it 'has legal document' do + render + expect(rendered).to have_css('[name="domain[legal_document]"]') + end +end From faeb7846734a46f28e7914c3920f09b7114897bc Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 5 Mar 2017 18:55:23 +0200 Subject: [PATCH 13/14] Remove ddoc legal document support in registrar area #270 --- app/helpers/application_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7e2e2d5352..8203a630ff 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -86,6 +86,7 @@ def changing_css_class(version, *attrs) def legal_document_types types = LegalDocument::TYPES.dup + types.delete('ddoc') ".#{types.join(',.')}" end end From 09d15a21693ce73a041f04bb4131d34f70ee04d9 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 5 Mar 2017 19:20:06 +0200 Subject: [PATCH 14/14] Add registrar area contact delete spec #270 --- .../registrar/contacts/delete_spec.rb | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 spec/features/registrar/contacts/delete_spec.rb diff --git a/spec/features/registrar/contacts/delete_spec.rb b/spec/features/registrar/contacts/delete_spec.rb new file mode 100644 index 0000000000..dd6305a109 --- /dev/null +++ b/spec/features/registrar/contacts/delete_spec.rb @@ -0,0 +1,52 @@ +require 'rails_helper' + +class FakeDeppContact + include ActiveModel::Model + + def id + 'test' + end + + def name + 'test' + end + + def persisted? + true + end + + def password + 'test' + end + + def delete + true + end +end + +RSpec.feature 'Contact deletion in registrar area' do + given!(:registrar) { create(:registrar) } + given!(:contact) { create(:contact, registrar: registrar) } + + background do + allow(Depp::Contact).to receive(:find_by_id).and_return(FakeDeppContact.new) + allow(Depp::Contact).to receive(:new).and_return(FakeDeppContact.new) + Setting.api_ip_whitelist_enabled = false + Setting.registrar_ip_whitelist_enabled = false + sign_in_to_registrar_area(user: create(:api_user_with_unlimited_balance, registrar: registrar)) + end + + it 'deletes contact' do + visit registrar_contacts_url + click_link_or_button 'Delete' + confirm + + expect(page).to have_text('Destroyed') + end + + private + + def confirm + click_link_or_button 'Delete' + end +end