change logic to generate a videocode

This commit is contained in:
Tyrel Souza 2014-04-25 16:02:47 -04:00
parent f7bd18de33
commit 6ae36b78d4
6 changed files with 34 additions and 15 deletions

View File

@ -29,7 +29,6 @@ class ApplicationController < ActionController::Base
user_email = params[:user_email].presence
token = params[:user_token]
end
log_it_in(token, user_email)
end

View File

@ -29,5 +29,4 @@ class VideolistingsController < ApplicationController
raise ActionController::RoutingError.new("Not Found by video code")
end
end

View File

@ -1,3 +1,5 @@
require 'securerandom'
class Videolisting < ActiveRecord::Base
belongs_to :campaign
validates :videocode, presence: true, uniqueness: true
@ -5,16 +7,29 @@ class Videolisting < ActiveRecord::Base
validates :musicselection, presence: true
after_save :send_notification_after_change
after_initialize :set_defaults
before_validation :set_videocode
def get_video_url
"http://video2.bettervideo.com/video/pro/MP4640x360/720.#{videocode}.mp4"
end
def set_defaults
self.producttypeid = 721
def get_preview_url
"http://video2.bettervideo.com/video/pro/jpg640x360/720.#{videocode}.jpg"
end
def asseturls_array
self.asseturls.split(',').collect { |url| { asseturl: url.strip } }
end
private
def set_videocode
self.videocode ||= SecureRandom.hex
end
def set_defaults
self.producttypeid = 721
end
def send_notification_after_change
if self.published_changed? && self.published?
#TODO: SEND OUT EMAIL HERE TO CLIENT SERVICES REP

View File

@ -1,7 +1,4 @@
<div class="nested-fields">
<%= f.input :videocode,
label: 'Video Code',
hint: "Unique identifier for every video." %>
<%= f.input :voiceoverselection,
label: 'Voiceover Selection',
collection: voiceoverselection_list,

View File

@ -2,8 +2,7 @@ require 'spec_helper'
describe ApplicationController do
it "can fail login" do
get "root#index"
end
it "can fail login"
it "can login with HTTP_AUTHORIZATION"
end

View File

@ -18,4 +18,14 @@ describe Videolisting, 'associations' do
listing = FactoryGirl.create(:videolisting)
expect(listing.asseturls_array).to include({asseturl: "http://s3.amazon.com/555555/catering.jpg"})
end
it "can get a video url" do
video = FactoryGirl.build(:videolisting)
expect(video.get_video_url).to include("http://video2.bettervideo.com/video/pro/MP4640x360/720")
end
it "can get a preview url" do
video = FactoryGirl.build(:videolisting)
expect(video.get_preview_url).to include("http://video2.bettervideo.com/video/pro/jpg640x360/720.")
end
end