change logic to generate a videocode
This commit is contained in:
parent
f7bd18de33
commit
6ae36b78d4
@ -29,7 +29,6 @@ class ApplicationController < ActionController::Base
|
|||||||
user_email = params[:user_email].presence
|
user_email = params[:user_email].presence
|
||||||
token = params[:user_token]
|
token = params[:user_token]
|
||||||
end
|
end
|
||||||
|
|
||||||
log_it_in(token, user_email)
|
log_it_in(token, user_email)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,5 +29,4 @@ class VideolistingsController < ApplicationController
|
|||||||
raise ActionController::RoutingError.new("Not Found by video code")
|
raise ActionController::RoutingError.new("Not Found by video code")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require 'securerandom'
|
||||||
|
|
||||||
class Videolisting < ActiveRecord::Base
|
class Videolisting < ActiveRecord::Base
|
||||||
belongs_to :campaign
|
belongs_to :campaign
|
||||||
validates :videocode, presence: true, uniqueness: true
|
validates :videocode, presence: true, uniqueness: true
|
||||||
@ -5,16 +7,29 @@ class Videolisting < ActiveRecord::Base
|
|||||||
validates :musicselection, presence: true
|
validates :musicselection, presence: true
|
||||||
after_save :send_notification_after_change
|
after_save :send_notification_after_change
|
||||||
after_initialize :set_defaults
|
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
|
def get_preview_url
|
||||||
self.producttypeid = 721
|
"http://video2.bettervideo.com/video/pro/jpg640x360/720.#{videocode}.jpg"
|
||||||
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
|
||||||
|
|
||||||
|
private
|
||||||
|
def set_videocode
|
||||||
|
self.videocode ||= SecureRandom.hex
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_defaults
|
||||||
|
self.producttypeid = 721
|
||||||
|
end
|
||||||
|
|
||||||
def send_notification_after_change
|
def send_notification_after_change
|
||||||
if self.published_changed? && self.published?
|
if self.published_changed? && self.published?
|
||||||
#TODO: SEND OUT EMAIL HERE TO CLIENT SERVICES REP
|
#TODO: SEND OUT EMAIL HERE TO CLIENT SERVICES REP
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
<div class="nested-fields">
|
<div class="nested-fields">
|
||||||
<%= f.input :videocode,
|
|
||||||
label: 'Video Code',
|
|
||||||
hint: "Unique identifier for every video." %>
|
|
||||||
<%= f.input :voiceoverselection,
|
<%= f.input :voiceoverselection,
|
||||||
label: 'Voiceover Selection',
|
label: 'Voiceover Selection',
|
||||||
collection: voiceoverselection_list,
|
collection: voiceoverselection_list,
|
||||||
|
@ -2,8 +2,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe ApplicationController do
|
describe ApplicationController do
|
||||||
|
|
||||||
it "can fail login" do
|
it "can fail login"
|
||||||
get "root#index"
|
it "can login with HTTP_AUTHORIZATION"
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
@ -18,4 +18,14 @@ describe Videolisting, 'associations' do
|
|||||||
listing = FactoryGirl.create(:videolisting)
|
listing = FactoryGirl.create(:videolisting)
|
||||||
expect(listing.asseturls_array).to include({asseturl: "http://s3.amazon.com/555555/catering.jpg"})
|
expect(listing.asseturls_array).to include({asseturl: "http://s3.amazon.com/555555/catering.jpg"})
|
||||||
end
|
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
|
end
|
Loading…
Reference in New Issue
Block a user