coverage up to 80%

This commit is contained in:
Tyrel Souza 2014-04-24 17:13:39 -04:00
parent 51ff3f421b
commit efb6d86ea8
7 changed files with 63 additions and 21 deletions

View File

@ -1,15 +1,4 @@
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={})
voiceoverselections = []
voiceoverselections << ["1 - Male", 1]
@ -30,8 +19,6 @@ module ApplicationHelper
return options.empty? ? musicselections : convert_to_hash(musicselections)[options[:item]]
end
def us_states(options={})
states = [
['Alabama', 'AL'],

View File

@ -8,16 +8,15 @@ class Campaign < ActiveRecord::Base
validates :productsandservices, presence: true
after_save :send_to_better_video
validate :has_at_least_one_videolisting
after_initialize :set_defaults
def set_defaults
self.clientid = 720
end
def has_at_least_one_videolisting
errors.add(:base, 'Must add at least one Videolisting') if self.videolistings.blank?
end
def init
self.clientid = 720
end
def send_to_better_video
if self.processed_changed? && self.processed == true

View File

@ -4,12 +4,13 @@ class Videolisting < ActiveRecord::Base
validates :voiceoverselection, presence: true
validates :musicselection, presence: true
after_save :send_notification_after_change
after_initialize :set_defaults
def init
def set_defaults
self.producttypeid = 721
end
def asseturls_array
self.asseturls.split(',').collect { |url| { asseturl: url.strip } }
end

View File

@ -51,4 +51,27 @@ describe CampaignsController do
expect(Campaign.last.videolistings.last.videocode).to eq videolisting[:videocode]
expect(Campaign.last.videolistings.count).to eq 1
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

View File

@ -1,7 +1,7 @@
FactoryGirl.define do
factory :campaign do
clientid 720
# clientid 720
sequence(:billingcode) { |x| "billingcode#{x}" }
sequence(:listingcode) { |x| "listingcode#{x}" }
address "123 Anywhere Street"

View 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

View File

@ -13,4 +13,9 @@ describe Videolisting, 'associations' do
expect(two.valid?).to be false
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