coverage up to 80%
This commit is contained in:
parent
51ff3f421b
commit
efb6d86ea8
@ -1,15 +1,4 @@
|
|||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
def producttypeid_list(options={})
|
|
||||||
producttypeids = []
|
|
||||||
producttypeids << ["720 - Basic Montage", 720]
|
|
||||||
producttypeids << ["721 - Advanced Montage", 721]
|
|
||||||
producttypeids << ["722 - Basic Video Shoot", 722]
|
|
||||||
producttypeids << ["723 - Repurposed", 723]
|
|
||||||
producttypeids << ["724 - Repurposed Edit", 724]
|
|
||||||
return options.empty? ? producttypeids : convert_to_hash(producttypeids)[options[:item]]
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def voiceoverselection_list(options={})
|
def voiceoverselection_list(options={})
|
||||||
voiceoverselections = []
|
voiceoverselections = []
|
||||||
voiceoverselections << ["1 - Male", 1]
|
voiceoverselections << ["1 - Male", 1]
|
||||||
@ -30,8 +19,6 @@ module ApplicationHelper
|
|||||||
return options.empty? ? musicselections : convert_to_hash(musicselections)[options[:item]]
|
return options.empty? ? musicselections : convert_to_hash(musicselections)[options[:item]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def us_states(options={})
|
def us_states(options={})
|
||||||
states = [
|
states = [
|
||||||
['Alabama', 'AL'],
|
['Alabama', 'AL'],
|
||||||
|
@ -8,16 +8,15 @@ class Campaign < ActiveRecord::Base
|
|||||||
validates :productsandservices, presence: true
|
validates :productsandservices, presence: true
|
||||||
after_save :send_to_better_video
|
after_save :send_to_better_video
|
||||||
validate :has_at_least_one_videolisting
|
validate :has_at_least_one_videolisting
|
||||||
|
after_initialize :set_defaults
|
||||||
|
def set_defaults
|
||||||
|
self.clientid = 720
|
||||||
|
end
|
||||||
def has_at_least_one_videolisting
|
def has_at_least_one_videolisting
|
||||||
errors.add(:base, 'Must add at least one Videolisting') if self.videolistings.blank?
|
errors.add(:base, 'Must add at least one Videolisting') if self.videolistings.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def init
|
|
||||||
self.clientid = 720
|
|
||||||
end
|
|
||||||
|
|
||||||
def send_to_better_video
|
def send_to_better_video
|
||||||
if self.processed_changed? && self.processed == true
|
if self.processed_changed? && self.processed == true
|
||||||
|
@ -4,12 +4,13 @@ class Videolisting < ActiveRecord::Base
|
|||||||
validates :voiceoverselection, presence: true
|
validates :voiceoverselection, presence: true
|
||||||
validates :musicselection, presence: true
|
validates :musicselection, presence: true
|
||||||
after_save :send_notification_after_change
|
after_save :send_notification_after_change
|
||||||
|
after_initialize :set_defaults
|
||||||
|
|
||||||
def init
|
|
||||||
|
def set_defaults
|
||||||
self.producttypeid = 721
|
self.producttypeid = 721
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def asseturls_array
|
def asseturls_array
|
||||||
self.asseturls.split(',').collect { |url| { asseturl: url.strip } }
|
self.asseturls.split(',').collect { |url| { asseturl: url.strip } }
|
||||||
end
|
end
|
||||||
|
@ -51,4 +51,27 @@ describe CampaignsController do
|
|||||||
expect(Campaign.last.videolistings.last.videocode).to eq videolisting[:videocode]
|
expect(Campaign.last.videolistings.last.videocode).to eq videolisting[:videocode]
|
||||||
expect(Campaign.last.videolistings.count).to eq 1
|
expect(Campaign.last.videolistings.count).to eq 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "expects the clientid to be correct" do
|
||||||
|
camp = FactoryGirl.build(:campaign)
|
||||||
|
expect(camp.clientid).to eq 720
|
||||||
|
end
|
||||||
|
|
||||||
|
it "allows you to set a campaign from a campaign that is a hash" do
|
||||||
|
#line 63 camp_controller
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't allow edits on an already published campaign" do
|
||||||
|
end
|
||||||
|
|
||||||
|
it "shows errors when creating and a campaign is invalid" do
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
it "it updates correctly." do
|
||||||
|
end
|
||||||
|
|
||||||
|
it "shows errors on failed updates" do
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
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}" }
|
||||||
sequence(:listingcode) { |x| "listingcode#{x}" }
|
sequence(:listingcode) { |x| "listingcode#{x}" }
|
||||||
address "123 Anywhere Street"
|
address "123 Anywhere Street"
|
||||||
|
27
spec/helpers/helpers_spec.rb
Normal file
27
spec/helpers/helpers_spec.rb
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe ApplicationHelper, 'helpers' do
|
||||||
|
it "gets all voiceovers" do
|
||||||
|
expect(voiceoverselection_list).to include(["1 - Male", 1])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "gets a voiceover" do
|
||||||
|
expect(voiceoverselection_list(item: 1)).to eq("1 - Male")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "gets all music selections" do
|
||||||
|
expect(musicselection_list).to include(["0 - No Preference", 0])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "gets a music selection" do
|
||||||
|
expect(musicselection_list(item: 0)).to eq("0 - No Preference")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "gets all states" do
|
||||||
|
expect(us_states).to include(['New Hampshire', 'NH'])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "gets a state" do
|
||||||
|
expect(us_states(item: 'NH')).to eq("New Hampshire")
|
||||||
|
end
|
||||||
|
end
|
@ -13,4 +13,9 @@ describe Videolisting, 'associations' do
|
|||||||
|
|
||||||
expect(two.valid?).to be false
|
expect(two.valid?).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "has asseturls array working correctly" do
|
||||||
|
listing = FactoryGirl.create(:videolisting)
|
||||||
|
expect(listing.asseturls_array).to include({asseturl: "http://s3.amazon.com/555555/catering.jpg"})
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user