From 7147144894e812ba6e724819326d351dde63f209 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 4 Sep 2017 10:57:27 +0300 Subject: [PATCH] Fix code climate offences #569 --- app/models/contact.rb | 6 ++-- app/models/epp/contact.rb | 5 ++- app/models/epp/response.rb | 2 +- app/models/epp/response/result.rb | 2 +- spec/models/contact/ident_spec.rb | 2 +- spec/models/epp/response/result_spec.rb | 2 +- .../requests/epp/contact/create/ident_spec.rb | 2 +- .../requests/epp/contact/update/ident_spec.rb | 35 +++++++++++++++---- 8 files changed, 38 insertions(+), 18 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 1bfca23c9..f04a16032 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -48,9 +48,9 @@ class Contact < ActiveRecord::Base composed_of :identifier, class_name: 'Contact::Ident', - constructor: Proc.new { |code, type, country_code| Contact::Ident.new(code: code, - type: type, - country_code: country_code) }, + constructor: proc { |code, type, country_code| Contact::Ident.new(code: code, + type: type, + country_code: country_code) }, mapping: [%w[ident code], %w[ident_type type], %w[ident_country_code country_code]] def manage_emails diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index a936045f5..5962c31e1 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -133,7 +133,7 @@ class Epp::Contact < Contact ], '2305' => [ # Association exists [:domains, :exist] - ], + ] } end @@ -165,8 +165,7 @@ class Epp::Contact < Contact identifier = Ident.new(code: ident, type: ident_frame.attr('type'), - country_code: ident_frame.attr('cc') - ) + country_code: ident_frame.attr('cc')) identifier.validate diff --git a/app/models/epp/response.rb b/app/models/epp/response.rb index 55f33c1bd..c9a5d8bb4 100644 --- a/app/models/epp/response.rb +++ b/app/models/epp/response.rb @@ -4,7 +4,7 @@ module EPP def self.from_xml(xml) xml_doc = Nokogiri::XML(xml) - response = self.new + response = new result_elements = xml_doc.css('result') diff --git a/app/models/epp/response/result.rb b/app/models/epp/response/result.rb index 2251587c0..5c870c830 100644 --- a/app/models/epp/response/result.rb +++ b/app/models/epp/response/result.rb @@ -9,7 +9,7 @@ module EPP '2001' => :syntax_error, '2003' => :required_param_missing, '2005' => :param_syntax_error, - '2308' => :data_management_policy_violation, + '2308' => :data_management_policy_violation } attr_accessor :code diff --git a/spec/models/contact/ident_spec.rb b/spec/models/contact/ident_spec.rb index f18dcc1ca..3b54b964c 100644 --- a/spec/models/contact/ident_spec.rb +++ b/spec/models/contact/ident_spec.rb @@ -164,7 +164,7 @@ RSpec.describe Contact::Ident, db: false do describe '::mismatches' do it 'returns mismatches' do mismatches = [ - Contact::Ident::Mismatch.new('birthday', Country.new('EE')), + Contact::Ident::Mismatch.new('birthday', Country.new('EE')) ] expect(described_class.mismatches).to eq(mismatches) diff --git a/spec/models/epp/response/result_spec.rb b/spec/models/epp/response/result_spec.rb index eaf136793..606a4c2de 100644 --- a/spec/models/epp/response/result_spec.rb +++ b/spec/models/epp/response/result_spec.rb @@ -12,7 +12,7 @@ RSpec.describe EPP::Response::Result, db: false do '2001' => :syntax_error, '2003' => :required_param_missing, '2005' => :param_syntax_error, - '2308' => :data_management_policy_violation, + '2308' => :data_management_policy_violation } expect(described_class.codes).to eq(codes) diff --git a/spec/requests/epp/contact/create/ident_spec.rb b/spec/requests/epp/contact/create/ident_spec.rb index f800a9102..b0a7254d8 100644 --- a/spec/requests/epp/contact/create/ident_spec.rb +++ b/spec/requests/epp/contact/create/ident_spec.rb @@ -219,7 +219,7 @@ RSpec.describe 'EPP contact:create' do before do mismatches = [ - Contact::Ident::Mismatch.new('priv', Country.new('DE')), + Contact::Ident::Mismatch.new('priv', Country.new('DE')) ] allow(Contact::Ident).to receive(:mismatches).and_return(mismatches) end diff --git a/spec/requests/epp/contact/update/ident_spec.rb b/spec/requests/epp/contact/update/ident_spec.rb index 5ecd0ef25..87879f35d 100644 --- a/spec/requests/epp/contact/update/ident_spec.rb +++ b/spec/requests/epp/contact/update/ident_spec.rb @@ -37,15 +37,24 @@ RSpec.describe 'EPP contact:update' do let!(:contact) { create(:contact, code: 'TEST', ident: 'test', ident_type: 'priv', ident_country_code: 'US') } it 'does not update code' do - expect { request; contact.reload }.to_not change { ident.code } + expect do + request + contact.reload + end.to_not change { ident.code } end it 'does not update type' do - expect { request; contact.reload }.to_not change { ident.type } + expect do + request + contact.reload + end.to_not change { ident.type } end it 'does not update country code' do - expect { request; contact.reload }.to_not change { ident.country_code } + expect do + request + contact.reload + end.to_not change { ident.country_code } end specify do @@ -90,7 +99,10 @@ RSpec.describe 'EPP contact:update' do } it 'does not update code' do - expect { request; contact.reload }.to_not change { ident.code } + expect do + request + contact.reload + end.to_not change { ident.code } end it 'updates type' do @@ -137,15 +149,24 @@ RSpec.describe 'EPP contact:update' do } it 'does not update code' do - expect { request; contact.reload }.to_not change { ident.code } + expect do + request + contact.reload + end.to_not change { ident.code } end it 'does not update type' do - expect { request; contact.reload }.to_not change { ident.type } + expect do + request + contact.reload + end.to_not change { ident.type } end it 'does not update country code' do - expect { request; contact.reload }.to_not change { ident.country_code } + expect do + request + contact.reload + end.to_not change { ident.country_code } end specify do