Fixing tests

This commit is contained in:
Tyrel Souza 2014-04-24 16:33:48 -04:00
parent e7c66e9c16
commit 4a4b97afd0
7 changed files with 19 additions and 26 deletions

View File

@ -67,7 +67,7 @@ class CampaignsController < ApplicationController
end end
def campaign_params def campaign_params
params.require(:campaign).permit(:id, :address, :advertisername, :awards, :background, :billingcode, params.require(:campaign).permit(:id, :address, :clientid, :advertisername, :awards, :background, :billingcode,
:businessphone, :categories, :city, :companycolors, :contactphone, :businessphone, :categories, :city, :companycolors, :contactphone,
:customerfirstname, :customerlastname, :description, :emailaddress, :facebookurl, :customerfirstname, :customerlastname, :description, :emailaddress, :facebookurl,
:listingcode, :productsandservices, :state, :targetaudience, :tollfreephone, :listingcode, :productsandservices, :state, :targetaudience, :tollfreephone,
@ -80,7 +80,7 @@ class CampaignsController < ApplicationController
end end
def not_found def not_found
raise ActionController::RoutingError.new("Not Found by clientid") raise ActionController::RoutingError.new("Not Found by listing code")
end end
def set_api_key def set_api_key

View File

@ -30,6 +30,9 @@ class VideolistingsController < ApplicationController
params.require(:videolisting).permit(:videocode, :producttypeid, :remoteassetsarchive, :voiceoverselection, :musicselection, :clientprovidedscript, :keywords, :focus, :notes, :asseturls) params.require(:videolisting).permit(:videocode, :producttypeid, :remoteassetsarchive, :voiceoverselection, :musicselection, :clientprovidedscript, :keywords, :focus, :notes, :asseturls)
end end
def not_found
raise ActionController::RoutingError.new("Not Found by video code")
end
end end

View File

@ -15,8 +15,9 @@ class Videolisting < ActiveRecord::Base
end end
def send_notification_after_change def send_notification_after_change
if self.published_changed? && self.published == true if self.published_changed? && self.published?
#TODO: SEND OUT EMAIL HERE. #TODO: SEND OUT EMAIL HERE TO CLIENT SERVICES REP
end end
true
end end
end end

View File

@ -21,14 +21,14 @@ describe CampaignsController do
end end
it 'raises routing error when campaign not found' do it 'raises routing error when campaign not found' do
expect(lambda { get :show, { :clientid => "x" } }).to raise_error(ActionController::RoutingError) expect(lambda { get :show, { :listingcode => "x" } }).to raise_error(ActionController::RoutingError)
end end
it 'creates a campaign from json post' do it 'creates a campaign from json post' do
post :create, campaign: campaign post :create, campaign: campaign
expect(response.status).to be 302 expect(response.status).to eq 302
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.")

View File

@ -1,4 +1,5 @@
FactoryGirl.define do FactoryGirl.define do
factory :campaign do factory :campaign do
clientid 720 clientid 720
sequence(:billingcode) { |x| "billingcode#{x}" } sequence(:billingcode) { |x| "billingcode#{x}" }
@ -25,5 +26,10 @@ FactoryGirl.define do
websiteurl "bobsbbq.com" websiteurl "bobsbbq.com"
zip "90200" zip "90200"
processed false processed false
after(:build) do |campaign, evaluator|
video = FactoryGirl.create(:videolisting)
campaign.videolistings << video
end
end end
end end

View File

@ -6,10 +6,10 @@ FactoryGirl.define do
clientprovidedscript "Bob's BBQ knows how to cater your next event..." clientprovidedscript "Bob's BBQ knows how to cater your next event..."
musicselection 5 musicselection 5
notes "Bob would like to focus on family gatherings" notes "Bob would like to focus on family gatherings"
producttypeid 720 producttypeid 721
toneofvideo "Upbeat, targeting familys but also show business functions." toneofvideo "Upbeat, targeting families but also show business functions."
voiceoverselection 3 voiceoverselection 3
published {|x| true }
sequence(:videocode) {|x| "video#{x}" } sequence(:videocode) {|x| "video#{x}" }
end end
end end

View File

@ -4,23 +4,6 @@ describe Campaign, 'associations' do
let(:campaign){ attributes_for :campaign } let(:campaign){ attributes_for :campaign }
it {should have_many(:videolistings) } 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 it 'disallows duplicate listingcode' do
one = Campaign.new(campaign) one = Campaign.new(campaign)