diff --git a/app/controllers/campaigns_controller.rb b/app/controllers/campaigns_controller.rb index f8c5fbb..589b055 100644 --- a/app/controllers/campaigns_controller.rb +++ b/app/controllers/campaigns_controller.rb @@ -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 diff --git a/app/controllers/videolistings_controller.rb b/app/controllers/videolistings_controller.rb index cdb062b..70aa7f2 100644 --- a/app/controllers/videolistings_controller.rb +++ b/app/controllers/videolistings_controller.rb @@ -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 diff --git a/app/models/videolisting.rb b/app/models/videolisting.rb index ae4f0f5..5610ecf 100644 --- a/app/models/videolisting.rb +++ b/app/models/videolisting.rb @@ -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. + if self.published_changed? && self.published? + #TODO: SEND OUT EMAIL HERE TO CLIENT SERVICES REP end + true end end diff --git a/spec/controllers/campaigns_controller_spec.rb b/spec/controllers/campaigns_controller_spec.rb index 756be06..13f15f9 100644 --- a/spec/controllers/campaigns_controller_spec.rb +++ b/spec/controllers/campaigns_controller_spec.rb @@ -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.") diff --git a/spec/factories/campaigns.rb b/spec/factories/campaigns.rb index 8587761..0084014 100644 --- a/spec/factories/campaigns.rb +++ b/spec/factories/campaigns.rb @@ -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 diff --git a/spec/factories/videolistings.rb b/spec/factories/videolistings.rb index ef15d4f..1ecae04 100644 --- a/spec/factories/videolistings.rb +++ b/spec/factories/videolistings.rb @@ -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 diff --git a/spec/models/campaign_spec.rb b/spec/models/campaign_spec.rb index ee003c9..b7131bf 100644 --- a/spec/models/campaign_spec.rb +++ b/spec/models/campaign_spec.rb @@ -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)