Fix code climate offences

#569
This commit is contained in:
Artur Beljajev 2017-09-04 10:57:27 +03:00
parent dbf5c8b4aa
commit 7147144894
8 changed files with 38 additions and 18 deletions

View file

@ -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

View file

@ -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

View file

@ -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')

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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