Added tests, cleaning up, TDDing, javascript
This commit is contained in:
parent
3b784fb493
commit
7ff11b8827
1
Gemfile
1
Gemfile
@ -23,6 +23,7 @@ gem 'devise'
|
|||||||
gem 'jbuilder'
|
gem 'jbuilder'
|
||||||
gem 'bootstrap-tagsinput-rails'
|
gem 'bootstrap-tagsinput-rails'
|
||||||
gem 'cocoon', :git => 'git://github.com/nathanvda/cocoon'
|
gem 'cocoon', :git => 'git://github.com/nathanvda/cocoon'
|
||||||
|
gem 'zeroclipboard-rails'
|
||||||
|
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
|
@ -227,6 +227,8 @@ GEM
|
|||||||
crack (>= 0.3.2)
|
crack (>= 0.3.2)
|
||||||
xpath (2.0.0)
|
xpath (2.0.0)
|
||||||
nokogiri (~> 1.3)
|
nokogiri (~> 1.3)
|
||||||
|
zeroclipboard-rails (0.0.12)
|
||||||
|
railties (>= 3.1)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
@ -270,3 +272,4 @@ DEPENDENCIES
|
|||||||
uglifier
|
uglifier
|
||||||
unicorn
|
unicorn
|
||||||
webmock
|
webmock
|
||||||
|
zeroclipboard-rails
|
||||||
|
@ -14,4 +14,5 @@
|
|||||||
//= require jquery_ujs
|
//= require jquery_ujs
|
||||||
//= require bootstrap-tagsinput
|
//= require bootstrap-tagsinput
|
||||||
//= require cocoon
|
//= require cocoon
|
||||||
|
//= require zeroclipboard
|
||||||
//= require_tree .
|
//= require_tree .
|
||||||
|
6
app/assets/javascripts/videolistings.js
Normal file
6
app/assets/javascripts/videolistings.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Created by tsouza on 4/28/14.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
class VideolistingsController < ApplicationController
|
class VideolistingsController < ApplicationController
|
||||||
before_action :set_videolisting, only: [:publish]
|
before_action :set_videolisting, only: [:publish, :show]
|
||||||
|
|
||||||
def publish
|
def publish
|
||||||
if @videolisting.published?
|
if @videolisting.published?
|
||||||
@ -14,6 +14,11 @@ class VideolistingsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def show
|
||||||
|
@videolisting
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_videolisting
|
def set_videolisting
|
||||||
|
@ -16,7 +16,12 @@ class Campaign < ActiveRecord::Base
|
|||||||
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 video_completion_percent
|
||||||
|
published = videolistings.where({published: true}).length
|
||||||
|
((published.to_f / videolistings.count.to_f) * 100).to_i
|
||||||
|
rescue
|
||||||
|
0
|
||||||
|
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
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
<ul>
|
<ul>
|
||||||
|
<% if videolisting.published %>
|
||||||
|
<li>
|
||||||
|
<p><strong>Published Video</strong><br>
|
||||||
|
<%= link_to "View Preview and Get Code", campaign_videolisting_path(@campaign.listingcode, videolisting.videocode) %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
<li>
|
<li>
|
||||||
<p><strong>Video Code</strong><br>
|
<p><strong>Video Code</strong><br>
|
||||||
<%= videolisting.videocode %></p>
|
<%= videolisting.videocode %></p>
|
||||||
|
@ -6,8 +6,9 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Listing Code (Form Hash)</th>
|
<th>Listing Code (Form Hash)</th>
|
||||||
|
<th>Advertiser</th>
|
||||||
<th>Processed?</th>
|
<th>Processed?</th>
|
||||||
<th>Billing Code</th>
|
<th>Percent of Videos Completed</th>
|
||||||
<th>Address</th>
|
<th>Address</th>
|
||||||
<th>City</th>
|
<th>City</th>
|
||||||
<th>State</th>
|
<th>State</th>
|
||||||
@ -20,8 +21,9 @@
|
|||||||
<% @campaigns.each do |campaign| %>
|
<% @campaigns.each do |campaign| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to campaign.listingcode, campaign_path(campaign.listingcode) %></td>
|
<td><%= link_to campaign.listingcode, campaign_path(campaign.listingcode) %></td>
|
||||||
|
<td><%= campaign.advertisername %></td>
|
||||||
<td><i class="glyphicon glyphicon-<% if campaign.processed? %>ok<% else %>remove<% end %>"></i> </td>
|
<td><i class="glyphicon glyphicon-<% if campaign.processed? %>ok<% else %>remove<% end %>"></i> </td>
|
||||||
<td><%= campaign.billingcode %></td>
|
<td><%= number_to_percentage(campaign.video_completion_percent, precision: 0) %></td>
|
||||||
<td><%= campaign.address %></td>
|
<td><%= campaign.address %></td>
|
||||||
<td><%= campaign.city %></td>
|
<td><%= campaign.city %></td>
|
||||||
<td><%= campaign.state %></td>
|
<td><%= campaign.state %></td>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<meta name="ROBOTS" content="NOODP" />
|
<meta name="ROBOTS" content="NOODP" />
|
||||||
<title><%= title %></title>
|
<title><%= title %></title>
|
||||||
<%= stylesheet_link_tag :application, :media => 'all' %>
|
<%= stylesheet_link_tag :application, :media => 'all' %>
|
||||||
|
<%= yield :js_head %>
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
</head>
|
</head>
|
||||||
<body class="<%= body_class %>">
|
<body class="<%= body_class %>">
|
||||||
|
46
app/views/videolistings/show.html.erb
Normal file
46
app/views/videolistings/show.html.erb
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<div class="container">
|
||||||
|
<section>
|
||||||
|
<div class="pull-right">
|
||||||
|
<%= link_to 'Back to Campaign', campaign_path(@videolisting.campaign.listingcode) %> |
|
||||||
|
<%= link_to 'Back to Campaigns List', campaigns_path %>
|
||||||
|
</div>
|
||||||
|
<h1><%= @videolisting.campaign.advertisername %> </h1>
|
||||||
|
<hr>
|
||||||
|
<p id="notice"><%= notice %></p>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<ul>
|
||||||
|
<li><h2>Video Code</h2>
|
||||||
|
Here is the video code:
|
||||||
|
|
||||||
|
<input type="text" id="videocode" value="<%= @videolisting.videocode %>"> <button class='clip_button' data-clipboard-target='videocode' data-clipboard-text='<%= @videolisting.videocode %>' id='clip_button' title='Click me to copy to clipboard.'>
|
||||||
|
<b>Copy To Clipboard...</b>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h3>Preview Image</h3>
|
||||||
|
|
||||||
|
<%= image_tag(@videolisting.get_preview_url) %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<% content_for :js_head do %>
|
||||||
|
<script>
|
||||||
|
$(document).on('ready page:load', function () {
|
||||||
|
var clip = new ZeroClipboard($("#clip_button"));
|
||||||
|
clip.on( "ready", function(readyEvent){
|
||||||
|
clip.on("aftercopy", function(event) {
|
||||||
|
alert("Copied text to clipboard: " + event.data["text/plain"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<% end %>
|
@ -9,7 +9,7 @@ FactoryGirl.define do
|
|||||||
producttypeid 721
|
producttypeid 721
|
||||||
toneofvideo "Upbeat, targeting families but also show business functions."
|
toneofvideo "Upbeat, targeting families but also show business functions."
|
||||||
voiceoverselection 3
|
voiceoverselection 3
|
||||||
published {|x| true }
|
published {|x| false }
|
||||||
sequence(:videocode) {|x| "video#{x}" }
|
sequence(:videocode) {|x| "video#{x}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,4 +14,30 @@ describe Campaign, 'associations' do
|
|||||||
expect(two.valid?).to be false
|
expect(two.valid?).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
it 'shows how complete the videos are by percentage' do
|
||||||
|
camp = Campaign.new(campaign)
|
||||||
|
video_1 = FactoryGirl.create(:videolisting)
|
||||||
|
video_2 = FactoryGirl.create(:videolisting)
|
||||||
|
|
||||||
|
expect(camp.video_completion_percent).to eq(0) # no associations
|
||||||
|
|
||||||
|
|
||||||
|
camp.videolistings << video_1
|
||||||
|
camp.videolistings << video_2
|
||||||
|
camp.save
|
||||||
|
|
||||||
|
expect(camp.video_completion_percent).to eq(0)
|
||||||
|
|
||||||
|
camp.videolistings.first.published = true
|
||||||
|
camp.videolistings.first.save
|
||||||
|
|
||||||
|
expect(camp.video_completion_percent).to eq(50)
|
||||||
|
|
||||||
|
camp.videolistings.last.published = true
|
||||||
|
camp.videolistings.last.save
|
||||||
|
|
||||||
|
expect(camp.video_completion_percent).to eq(100)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user