all tests pass with devise added. bootstrap cleanup.
This commit is contained in:
parent
dedc9b782e
commit
9c32679ce9
@ -1,12 +1,13 @@
|
|||||||
$medgray: #666;
|
$medgray: #666;
|
||||||
|
|
||||||
|
|
||||||
.videolisting {
|
.videolisting {
|
||||||
label {
|
label {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
input {border: 2px inset;}
|
|
||||||
|
|
||||||
|
input {
|
||||||
|
border: 2px inset;
|
||||||
|
}
|
||||||
|
|
||||||
.odd {
|
.odd {
|
||||||
background-color: $medgray;
|
background-color: $medgray;
|
||||||
@ -15,7 +16,6 @@ $medgray: #666;
|
|||||||
.even {
|
.even {
|
||||||
background-color: lighten($medgray, 50);
|
background-color: lighten($medgray, 50);
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,4 +2,6 @@ class ApplicationController < ActionController::Base
|
|||||||
# Prevent CSRF attacks by raising an exception.
|
# Prevent CSRF attacks by raising an exception.
|
||||||
# For APIs, you may want to use :null_session instead.
|
# For APIs, you may want to use :null_session instead.
|
||||||
protect_from_forgery with: :null_session
|
protect_from_forgery with: :null_session
|
||||||
|
before_action :authenticate_user! #unless Rails.env.test?
|
||||||
|
|
||||||
end
|
end
|
||||||
|
11
app/controllers/registrations_controller.rb
Normal file
11
app/controllers/registrations_controller.rb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
class RegistrationsController < Devise::RegistrationsController
|
||||||
|
def new
|
||||||
|
flash[:info] = "Registrations are not open, please contact DEV."
|
||||||
|
redirect_to user_session_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
flash[:info] = "Registrations are not open, please contact DEV."
|
||||||
|
redirect_to user_session_path
|
||||||
|
end
|
||||||
|
end
|
@ -1,14 +1,14 @@
|
|||||||
<h1>Listing campaigns</h1>
|
<h1>Listing campaigns</h1>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Clientid</th>
|
<th>Client ID</th>
|
||||||
<th>Listingcode</th>
|
<th>Listing Code</th>
|
||||||
<th>Address1</th>
|
<th>Address</th>
|
||||||
<th>City</th>
|
<th>City</th>
|
||||||
<th>State</th>
|
<th>State</th>
|
||||||
<th>Zip</th>
|
<th>ZIP</th>
|
||||||
<th></th>
|
<th>Processed?</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -17,13 +17,13 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<% @campaigns.each do |campaign| %>
|
<% @campaigns.each do |campaign| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= campaign.clientid %></td>
|
<td><%= link_to campaign.clientid, campaign_path(campaign.clientid) %></td>
|
||||||
<td><%= campaign.listingcode %></td>
|
<td><%= campaign.listingcode %></td>
|
||||||
<td><%= campaign.address1 %></td>
|
<td><%= campaign.address1 %></td>
|
||||||
<td><%= campaign.city %></td>
|
<td><%= campaign.city %></td>
|
||||||
<td><%= campaign.state %></td>
|
<td><%= campaign.state %></td>
|
||||||
<td><%= campaign.zip %></td>
|
<td><%= campaign.zip %></td>
|
||||||
<td><%= link_to 'Show', campaign_path(campaign.clientid) %></td>
|
<td><%= campaign.processed? %></td>
|
||||||
<td><%= link_to 'Edit', edit_campaign_path(campaign.clientid) %></td>
|
<td><%= link_to 'Edit', edit_campaign_path(campaign.clientid) %></td>
|
||||||
<td><%= link_to 'Destroy', campaign_path(campaign.clientid), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
<td><%= link_to 'Destroy', campaign_path(campaign.clientid), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<div class="row">
|
<%= link_to 'Edit', edit_campaign_path(@campaign.clientid) %> |
|
||||||
<div class="small-6 medium-6 large-6 columns">
|
<%= link_to 'Back', campaigns_path %>
|
||||||
|
|
||||||
|
<div class="col-md-2"></div>
|
||||||
|
<div class="col-md-4">
|
||||||
<p id="notice"><%= notice %></p>
|
<p id="notice"><%= notice %></p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -87,7 +90,7 @@
|
|||||||
<%= @campaign.websiteurl %>
|
<%= @campaign.websiteurl %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-6 medium-6 large-6 columns">
|
<div class="col-md-4">
|
||||||
<ul>
|
<ul>
|
||||||
<% @campaign.videolistings.each do |vl| %>
|
<% @campaign.videolistings.each do |vl| %>
|
||||||
<li>
|
<li>
|
||||||
@ -139,9 +142,5 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-2"></div>
|
||||||
<%= link_to 'Edit', edit_campaign_path(@campaign) %> |
|
|
||||||
<%= link_to 'Back', campaigns_path %>
|
|
||||||
|
@ -8,10 +8,11 @@
|
|||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
</head>
|
</head>
|
||||||
<body class="<%= body_class %>">
|
<body class="<%= body_class %>">
|
||||||
|
<div class="col-md-12">
|
||||||
<%= render 'layouts/header' %>
|
<%= render 'layouts/header' %>
|
||||||
<%= render 'flashes' -%>
|
<%= render 'flashes' -%>
|
||||||
|
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
|
</div>
|
||||||
<%= render 'javascript' %>
|
<%= render 'javascript' %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
48
config/initializers/simple_form_bootstrap.rb
Normal file
48
config/initializers/simple_form_bootstrap.rb
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# Use this setup block to configure all options available in SimpleForm.
|
||||||
|
SimpleForm.setup do |config|
|
||||||
|
config.error_notification_class = 'alert alert-error'
|
||||||
|
config.label_class = 'control-label'
|
||||||
|
|
||||||
|
config.wrappers :bootstrap, tag: 'div', class: 'control-group', error_class: 'error' do |b|
|
||||||
|
b.use :html5
|
||||||
|
b.use :placeholder
|
||||||
|
b.use :label
|
||||||
|
b.wrapper tag: 'div', class: 'controls' do |ba|
|
||||||
|
ba.use :input
|
||||||
|
ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
||||||
|
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b|
|
||||||
|
b.use :html5
|
||||||
|
b.use :placeholder
|
||||||
|
b.use :label
|
||||||
|
b.wrapper tag: 'div', class: 'controls' do |input|
|
||||||
|
input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
|
||||||
|
prepend.use :input
|
||||||
|
end
|
||||||
|
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
|
||||||
|
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b|
|
||||||
|
b.use :html5
|
||||||
|
b.use :placeholder
|
||||||
|
b.use :label
|
||||||
|
b.wrapper tag: 'div', class: 'controls' do |input|
|
||||||
|
input.wrapper tag: 'div', class: 'input-append' do |append|
|
||||||
|
append.use :input
|
||||||
|
end
|
||||||
|
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
|
||||||
|
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Wrappers for forms and inputs using the Bootstrap toolkit.
|
||||||
|
# Check the Bootstrap docs (http://getbootstrap.com/2.3.2/)
|
||||||
|
# to learn about the different styles for forms and inputs,
|
||||||
|
# buttons and other elements.
|
||||||
|
config.default_wrapper = :bootstrap
|
||||||
|
end
|
@ -1,6 +1,11 @@
|
|||||||
Vidpush::Application.routes.draw do
|
Vidpush::Application.routes.draw do
|
||||||
devise_for :admins
|
devise_for :admins
|
||||||
devise_for :users
|
if Rails.env.production?
|
||||||
|
devise_for :users, :controllers => {registrations: "registrations"}
|
||||||
|
else
|
||||||
|
devise_for :users, :controllers => {registrations: "registrations"}
|
||||||
|
|
||||||
|
end
|
||||||
root to: "campaigns#index"
|
root to: "campaigns#index"
|
||||||
|
|
||||||
resources :campaigns, param: :clientid
|
resources :campaigns, param: :clientid
|
||||||
|
5
db/migrate/20140409152531_add_processed_to_campaigns.rb
Normal file
5
db/migrate/20140409152531_add_processed_to_campaigns.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class AddProcessedToCampaigns < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :campaigns, :processed, :boolean, default: nil
|
||||||
|
end
|
||||||
|
end
|
@ -1,18 +1,31 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe CampaignsController do
|
describe CampaignsController do
|
||||||
|
before (:each) do
|
||||||
|
@user = FactoryGirl.create(:user)
|
||||||
|
sign_in @user
|
||||||
|
end
|
||||||
|
|
||||||
let(:campaign){ attributes_for :campaign }
|
let(:campaign){ attributes_for :campaign }
|
||||||
let(:videolisting){ attributes_for :videolisting }
|
let(:videolisting){ attributes_for :videolisting }
|
||||||
|
|
||||||
it 'creates a campaign from json post' do
|
it 'creates a campaign from json post' do
|
||||||
post :create, campaign: campaign
|
post :create, campaign: campaign
|
||||||
|
|
||||||
expect(response.status).to be 302
|
expect(response.status).to be 302
|
||||||
|
flash = response.request.env["action_dispatch.request.flash_hash"][:alert]
|
||||||
|
|
||||||
|
expect(flash).not_to eq("You need to sign in or sign up before continuing.")
|
||||||
expect(Campaign.last.clientid).to eq campaign[:clientid]
|
expect(Campaign.last.clientid).to eq campaign[:clientid]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a campaign with a nested videolisting' do
|
it 'creates a campaign with a nested videolisting' do
|
||||||
campaign[:videolistings_attributes] = [videolisting,]
|
campaign[:videolistings_attributes] = [videolisting,]
|
||||||
post :create, campaign: campaign
|
post :create, campaign: campaign
|
||||||
|
|
||||||
|
flash = response.request.env["action_dispatch.request.flash_hash"][:alert]
|
||||||
|
expect(flash).not_to eq("You need to sign in or sign up before continuing.")
|
||||||
|
|
||||||
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
|
||||||
|
7
spec/factories/admins.rb
Normal file
7
spec/factories/admins.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
FactoryGirl.define do
|
||||||
|
factory :admin do
|
||||||
|
email {|x| "johnny#{x}@doe.com"}
|
||||||
|
password { "password" }
|
||||||
|
password_confirmation { "password" }
|
||||||
|
end
|
||||||
|
end
|
7
spec/factories/users.rb
Normal file
7
spec/factories/users.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
FactoryGirl.define do
|
||||||
|
factory :user do
|
||||||
|
email {|x| "johnny#{x}@doe.com"}
|
||||||
|
password { "password" }
|
||||||
|
password_confirmation { "password" }
|
||||||
|
end
|
||||||
|
end
|
@ -28,3 +28,4 @@ end
|
|||||||
|
|
||||||
Capybara.javascript_driver = :webkit
|
Capybara.javascript_driver = :webkit
|
||||||
WebMock.disable_net_connect!(allow_localhost: true)
|
WebMock.disable_net_connect!(allow_localhost: true)
|
||||||
|
|
||||||
|
3
spec/support/devise.rb
Normal file
3
spec/support/devise.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
RSpec.configure do |config|
|
||||||
|
config.include Devise::TestHelpers, type: :controller
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user