From 48f752adf7a0c473266ac074dff61881c1434fc9 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 19 Dec 2016 08:59:34 +0200 Subject: [PATCH] Do not show address at contact view in registrar area unless address_processing is enabled #251 --- app/views/registrar/contacts/show.haml | 2 +- .../registrar/contacts/show.haml_spec.rb | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 spec/views/registrar/contacts/show.haml_spec.rb diff --git a/app/views/registrar/contacts/show.haml b/app/views/registrar/contacts/show.haml index f12e22b84f..9fb23182d1 100644 --- a/app/views/registrar/contacts/show.haml +++ b/app/views/registrar/contacts/show.haml @@ -6,7 +6,7 @@ .row .col-md-6= render 'registrar/contacts/partials/general' - .col-md-6= render 'registrar/contacts/partials/address' + .col-md-6= render 'registrar/contacts/partials/address' if Contact.address_processing? .row .col-md-12= render 'registrar/contacts/partials/statuses', statuses: @contact.statuses .row diff --git a/spec/views/registrar/contacts/show.haml_spec.rb b/spec/views/registrar/contacts/show.haml_spec.rb new file mode 100644 index 0000000000..65fca28632 --- /dev/null +++ b/spec/views/registrar/contacts/show.haml_spec.rb @@ -0,0 +1,36 @@ +require 'rails_helper' + +RSpec.describe 'registrar/contacts/show' do + let(:contact) { instance_spy(Depp::Contact, id: 1, name: 'test') } + + before do + assign(:contact, contact) + stub_template 'shared/_title' => '' + stub_template 'registrar/contacts/partials/_general' => '' + stub_template 'registrar/contacts/partials/_statuses' => '' + stub_template 'registrar/contacts/partials/_domains' => '' + stub_template 'registrar/contacts/partials/_address' => 'address info' + end + + context 'when address processing is enabled' do + before do + allow(Contact).to receive(:address_processing?).and_return(true) + end + + it 'has address' do + render + expect(rendered).to have_text('address info') + end + end + + context 'when address processing is disabled' do + before do + allow(Contact).to receive(:address_processing?).and_return(false) + end + + it 'has no address' do + render + expect(rendered).to_not have_text('address info') + end + end +end