fix tests

This commit is contained in:
Tyrel Souza 2014-04-30 15:53:58 -04:00
parent 63044d2499
commit 2414ce8276
2 changed files with 10 additions and 5 deletions

View File

@ -28,8 +28,10 @@ class Videolisting < ActiveRecord::Base
end
def fix_videocode
self.videocode = "#{self.campaign.listingcode}-#{self.id}"
self.save
if self.campaign
self.videocode = "#{self.campaign.listingcode}-#{self.id}"
self.save
end
end
def set_defaults

View File

@ -61,13 +61,16 @@ describe CampaignsController do
it 'creates a campaign with a nested videolisting' do
campaign[:videolistings_attributes] = [videolisting,]
post :create, campaign: campaign
expect do
post :create, campaign: campaign
end.to change(Campaign, :count).by(1)
flash = response.request.env["action_dispatch.request.flash_hash"][:alert]
expect(flash).not_to eq("You need to sign in or sign up before continuing.")
expect(Campaign.last.videolistings.last.videocode).to eq videolisting[:videocode]
expect(Campaign.last.videolistings.count).to eq 1
end
it "expects the clientid to be correct" do