From f5e7f23ddf687afc5628ab730d8e71a8762ff878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Wed, 22 Oct 2014 12:36:32 +0300 Subject: [PATCH] Fixed tests --- app/models/contact.rb | 2 +- app/models/domain.rb | 8 ++++---- app/models/domain_contact.rb | 1 + config/environments/test.rb | 2 +- spec/epp/contact_spec.rb | 22 ---------------------- spec/models/address_spec.rb | 3 +-- 6 files changed, 8 insertions(+), 30 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 3169cc4b8..88be4e65f 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -66,7 +66,7 @@ class Contact < ActiveRecord::Base def domains_snapshot (domains + domains_owned).uniq.each do |domain| next unless domain.is_a?(Domain) - #next if domain.versions.last == domain.create_snapshot + # next if domain.versions.last == domain.create_snapshot domain.create_version # Method from paper_trail end end diff --git a/app/models/domain.rb b/app/models/domain.rb index cc3a3eaa7..4e3f6a937 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -62,7 +62,7 @@ class Domain < ActiveRecord::Base # archiving # if proc works only on changes on domain sadly - has_paper_trail class_name: 'DomainVersion', meta: { snapshot: :create_snapshot }, if: Proc.new{ |t| t.new_version } + has_paper_trail class_name: 'DomainVersion', meta: { snapshot: :create_snapshot }, if: proc(&:new_version) def new_version return false if versions.try(:last).try(:snapshot) == create_snapshot @@ -75,10 +75,10 @@ class Domain < ActiveRecord::Base touch_with_version if new_version end - def track_nameserver_add(nameserver) + def track_nameserver_add(_nameserver) + return true if versions.count == 0 return true unless valid? && new_version - ns_created = nameserver.created_at.to_i - return true if created_at.to_i.between?( ns_created, ns_created + 1 ) + touch_with_version end diff --git a/app/models/domain_contact.rb b/app/models/domain_contact.rb index 584b3571b..82332c0dc 100644 --- a/app/models/domain_contact.rb +++ b/app/models/domain_contact.rb @@ -40,6 +40,7 @@ class DomainContact < ActiveRecord::Base def domain_snapshot return true if domain.nil? + return true if domain.versions.count == 0 # avoid snapshot on creation domain.create_version true end diff --git a/config/environments/test.rb b/config/environments/test.rb index f69df6cd3..dfc9384e2 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -41,6 +41,6 @@ Rails.application.configure do config.after_initialize do Bullet.enable = true Bullet.bullet_logger = true - Bullet.raise = false # raise an error if n+1 query occurs + Bullet.raise = true # raise an error if n+1 query occurs end end diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 64fd34e78..5f91c3e04 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -80,18 +80,6 @@ describe 'EPP Contact', epp: true do expect(id.text.length).to eq(8) # 5 seconds for what-ever weird lag reasons might happen expect(cr_date.text.to_time).to be_within(5).of(Time.now) - - end - - it 'does not create duplicate contact', pending: true do - Fabricate(:contact, code: 'sh8013') - - response = epp_request(contact_create_xml, :xml) - - expect(response[:result_code]).to eq('2302') - expect(response[:msg]).to eq('Contact id already exists') - - expect(Contact.count).to eq(1) end end @@ -115,16 +103,6 @@ describe 'EPP Contact', epp: true do expect(response[:result_code]).to eq('2201') end - it 'stamps updated_by succesfully', pending: true do - Fabricate(:contact, code: 'sh8013', created_by_id: zone.id) - - expect(Contact.first.updated_by_id).to be nil - - epp_request(contact_update_xml, :xml) - - expect(Contact.first.updated_by_id).to eq 2 - end - it 'is succesful' do Fabricate( :contact, diff --git a/spec/models/address_spec.rb b/spec/models/address_spec.rb index 668f2d964..5eb80854b 100644 --- a/spec/models/address_spec.rb +++ b/spec/models/address_spec.rb @@ -7,8 +7,7 @@ end describe Address, '.extract_params' do - # TODO: please fix - it 'returns params hash', pending: true do + it 'returns params hash' do Fabricate(:country, iso: 'EE') ph = { postalInfo: { name: 'fred', addr: { cc: 'EE', city: 'Village', street: %w(street1 street2) } } } expect(Address.extract_attributes(ph[:postalInfo])).to eq({