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,9 +28,11 @@ class Videolisting < ActiveRecord::Base
end end
def fix_videocode def fix_videocode
if self.campaign
self.videocode = "#{self.campaign.listingcode}-#{self.id}" self.videocode = "#{self.campaign.listingcode}-#{self.id}"
self.save self.save
end end
end
def set_defaults def set_defaults
self.producttypeid = 721 self.producttypeid = 721

View File

@ -61,13 +61,16 @@ describe CampaignsController do
it 'creates a campaign with a nested videolisting' do it 'creates a campaign with a nested videolisting' do
campaign[:videolistings_attributes] = [videolisting,] campaign[:videolistings_attributes] = [videolisting,]
expect do
post :create, campaign: campaign post :create, campaign: campaign
end.to change(Campaign, :count).by(1)
flash = response.request.env["action_dispatch.request.flash_hash"][:alert] 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(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 end
it "expects the clientid to be correct" do it "expects the clientid to be correct" do