From b52ec4e35e6932ab168dc5f60269a298629dc94f Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Mon, 16 Mar 2015 17:23:05 +0200 Subject: [PATCH 1/2] Disabled fax --- app/controllers/epp/contacts_controller.rb | 11 ++++++++++ config/locales/en.yml | 1 + spec/epp/contact_spec.rb | 25 +++++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/app/controllers/epp/contacts_controller.rb b/app/controllers/epp/contacts_controller.rb index a30ab5649..983490e8c 100644 --- a/app/controllers/epp/contacts_controller.rb +++ b/app/controllers/epp/contacts_controller.rb @@ -100,6 +100,7 @@ class Epp::ContactsController < EppController } end contact_org_disabled + fax_disabled @prefix = nil requires 'extension > extdata > ident' end @@ -113,6 +114,7 @@ class Epp::ContactsController < EppController } end contact_org_disabled + fax_disabled requires 'id', 'authInfo > pw' @prefix = nil end @@ -131,4 +133,13 @@ class Epp::ContactsController < EppController msg: "#{I18n.t(:contact_org_error)}: postalInfo > org [org]" } end + + def fax_disabled + return true if ENV['fax_enabled'] == 'true' + return true if params[:parsed_frame].css('fax').text.blank? + epp_errors << { + code: '2306', + msg: "#{I18n.t(:contact_fax_error)}: fax [fax]" + } + end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 0c201eb67..d4ed0cefc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -491,3 +491,4 @@ en: revoke_this_certificate: 'Revoke this certificate' crt_revoked: 'CRT (revoked)' contact_org_error: 'Parameter value policy error. Org should be blank' + contact_fax_error: 'Parameter value policy error. Fax should be blank' diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 1e6ab1be5..ca5edd28f 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -145,7 +145,7 @@ describe 'EPP Contact', epp: true do Contact.last.code.should == 'registrar1:12345' end - it 'should return parameter value policy errror' do + it 'should return parameter value policy error for org' do response = create_request({ postalInfo: { org: { value: 'should not save' } } }) response[:msg].should == 'Parameter value policy error. Org should be blank: postalInfo > org [org]' @@ -153,6 +153,15 @@ describe 'EPP Contact', epp: true do Contact.last.org_name.should == nil end + + it 'should return parameter value policy error for fax' do + response = create_request({ fax: { value: 'should not save' } }) + response[:msg].should == + 'Parameter value policy error. Fax should be blank: fax [fax]' + response[:result_code].should == '2306' + + Contact.last.fax.should == nil + end end context 'update command' do @@ -289,6 +298,20 @@ describe 'EPP Contact', epp: true do Contact.find_by(code: 'sh8013').org_name.should == nil end + + it 'should return parameter value policy errror for fax update' do + response = update_request({ + id: { value: 'sh8013' }, + chg: { + fax: { value: 'should not save' } + } + }) + response[:msg].should == + 'Parameter value policy error. Fax should be blank: fax [fax]' + response[:result_code].should == '2306' + + Contact.find_by(code: 'sh8013').fax.should == nil + end end context 'delete command' do From 1264cde50d88ae7f8e06a550de71af5c1b1e4d22 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 17 Mar 2015 11:20:17 +0200 Subject: [PATCH 2/2] refactor ident_for helper --- app/helpers/application_helper.rb | 6 +++--- app/views/admin/contacts/index.haml | 4 ++-- app/views/admin/contacts/partials/_general.haml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0c51ce5a7..9153b1911 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -9,12 +9,12 @@ module ApplicationHelper "background-image: url(#{image_path(unstable_env.to_s + '.png')});" end - def ident_indicator(contact) + def ident_for(contact) case contact.ident_type when 'birthday' - "[#{contact.ident_type}]" + "#{contact.ident} [#{contact.ident_type}]" else - "[#{contact.ident_country_code} #{contact.ident_type}]" + "#{contact.ident} [#{contact.ident_country_code} #{contact.ident_type}]" end end end diff --git a/app/views/admin/contacts/index.haml b/app/views/admin/contacts/index.haml index afc2bba35..e25620663 100644 --- a/app/views/admin/contacts/index.haml +++ b/app/views/admin/contacts/index.haml @@ -1,6 +1,6 @@ .row .col-sm-12 - %h2.text-center-xs= t('contacts') + %h2.text-center-xs= t(:contacts) %hr .row .col-md-12 @@ -35,7 +35,7 @@ - @contacts.each do |contact| %tr %td= link_to(contact, admin_contact_path(contact)) - %td= "#{contact.ident} #{ident_indicator(contact)}" + %td= ident_for(contact) %td= contact.email %td= contact.code %td diff --git a/app/views/admin/contacts/partials/_general.haml b/app/views/admin/contacts/partials/_general.haml index 6fe250c2d..2504bbc97 100644 --- a/app/views/admin/contacts/partials/_general.haml +++ b/app/views/admin/contacts/partials/_general.haml @@ -4,7 +4,7 @@ .panel-body %dl.dl-horizontal %dt= t(:ident) - %dd= "#{@contact.ident} #{ident_indicator(@contact)}" + %dd= ident_for(@contact) %br