spec/models/account_domain_spec.rb in iugusdk-1.0.0.alpha.2 vs spec/models/account_domain_spec.rb in iugusdk-1.0.0.alpha.3
- old
+ new
@@ -9,11 +9,11 @@
it { should validate_presence_of(:url) }
it { should validate_presence_of(:account_id) }
it 'should accept url with correct pattern' do
@account = Fabricate(:account)
- @domain = AccountDomain.create(:url => 'valid.url.test', :account => @account)
+ @account.account_domains << @domain = AccountDomain.create(:url => 'valid.url.test')
@domain.valid?.should be_true
end
it 'should not accept url with incorrect pattern' do
@account = Fabricate(:account)
@@ -46,11 +46,13 @@
end
end
it 'should set the first verified domain as primary if the primary domain is destroyed' do
@account = Fabricate(:account)
- @account.account_domains << @domain1 = AccountDomain.create(:url => "url1.test.test", :verified => true)
- @account.account_domains << @domain2 = AccountDomain.create(:url => "url2.test.test", :verified => true)
+ @account.account_domains << @domain1 = AccountDomain.create(:url => "url1.test.test")
+ @account.account_domains << @domain2 = AccountDomain.create(:url => "url2.test.test")
+ @domain1.update_attribute(:verified, true)
+ @domain2.update_attribute(:verified, true)
@domain1.set_primary
@domain1.destroy
@domain2.reload
@domain2.primary.should be_true
end