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
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,
:customerfirstname, :customerlastname, :description, :emailaddress, :facebookurl,
:listingcode, :productsandservices, :state, :targetaudience, :tollfreephone,
@ -80,7 +80,7 @@ class CampaignsController < ApplicationController
end
def not_found
raise ActionController::RoutingError.new("Not Found by clientid")
raise ActionController::RoutingError.new("Not Found by listing code")
end
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)
end
def not_found
raise ActionController::RoutingError.new("Not Found by video code")
end
end

View File

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

View File

@ -21,14 +21,14 @@ describe CampaignsController do
end
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
it 'creates a campaign from json post' do
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]
expect(flash).not_to eq("You need to sign in or sign up before continuing.")

View File

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

View File

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

View File

@ -4,23 +4,6 @@ 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)