require 'spec_helper' describe Campaign, 'associations' do let(:campaign){ attributes_for :campaign } it {should have_many(:videolistings) } it 'disallows duplicate campaignid' do one = Campaign.new(campaign) one.save two = Campaign.new(campaign) two.clientid = one.clientid expect(two.valid?).to be false end it 'disallows duplicate billingcode' do one = Campaign.new(campaign) one.save two = Campaign.new(campaign) two.billingcode = one.billingcode expect(two.valid?).to be false end it 'disallows duplicate listingcode' do one = Campaign.new(campaign) one.save two = Campaign.new(campaign) two.listingcode = one.listingcode expect(two.valid?).to be false end end