all tests pass with devise added. bootstrap cleanup.
This commit is contained in:
parent
dedc9b782e
commit
9c32679ce9
@ -1,12 +1,13 @@
|
||||
$medgray: #666;
|
||||
|
||||
|
||||
.videolisting {
|
||||
label {
|
||||
color: #fff;
|
||||
}
|
||||
input {border: 2px inset;}
|
||||
|
||||
input {
|
||||
border: 2px inset;
|
||||
}
|
||||
|
||||
.odd {
|
||||
background-color: $medgray;
|
||||
@ -15,7 +16,6 @@ $medgray: #666;
|
||||
.even {
|
||||
background-color: lighten($medgray, 50);
|
||||
padding: 10px;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,4 +2,6 @@ class ApplicationController < ActionController::Base
|
||||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :null_session
|
||||
before_action :authenticate_user! #unless Rails.env.test?
|
||||
|
||||
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
|
@ -2,13 +2,13 @@
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Clientid</th>
|
||||
<th>Listingcode</th>
|
||||
<th>Address1</th>
|
||||
<th>Client ID</th>
|
||||
<th>Listing Code</th>
|
||||
<th>Address</th>
|
||||
<th>City</th>
|
||||
<th>State</th>
|
||||
<th>Zip</th>
|
||||
<th></th>
|
||||
<th>ZIP</th>
|
||||
<th>Processed?</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@ -17,13 +17,13 @@
|
||||
<tbody>
|
||||
<% @campaigns.each do |campaign| %>
|
||||
<tr>
|
||||
<td><%= campaign.clientid %></td>
|
||||
<td><%= link_to campaign.clientid, campaign_path(campaign.clientid) %></td>
|
||||
<td><%= campaign.listingcode %></td>
|
||||
<td><%= campaign.address1 %></td>
|
||||
<td><%= campaign.city %></td>
|
||||
<td><%= campaign.state %></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 'Destroy', campaign_path(campaign.clientid), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
|
@ -1,5 +1,8 @@
|
||||
<div class="row">
|
||||
<div class="small-6 medium-6 large-6 columns">
|
||||
<%= link_to 'Edit', edit_campaign_path(@campaign.clientid) %> |
|
||||
<%= link_to 'Back', campaigns_path %>
|
||||
|
||||
<div class="col-md-2"></div>
|
||||
<div class="col-md-4">
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
@ -87,7 +90,7 @@
|
||||
<%= @campaign.websiteurl %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="small-6 medium-6 large-6 columns">
|
||||
<div class="col-md-4">
|
||||
<ul>
|
||||
<% @campaign.videolistings.each do |vl| %>
|
||||
<li>
|
||||
@ -139,9 +142,5 @@
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= link_to 'Edit', edit_campaign_path(@campaign) %> |
|
||||
<%= link_to 'Back', campaigns_path %>
|
||||
<div class="col-md-2"></div>
|
||||
|
@ -8,10 +8,11 @@
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body class="<%= body_class %>">
|
||||
<div class="col-md-12">
|
||||
<%= render 'layouts/header' %>
|
||||
<%= render 'flashes' -%>
|
||||
|
||||
<%= yield %>
|
||||
</div>
|
||||
<%= render 'javascript' %>
|
||||
</body>
|
||||
</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
|
||||
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"
|
||||
|
||||
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'
|
||||
|
||||
describe CampaignsController do
|
||||
before (:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
sign_in @user
|
||||
end
|
||||
|
||||
let(:campaign){ attributes_for :campaign }
|
||||
let(:videolisting){ attributes_for :videolisting }
|
||||
|
||||
it 'creates a campaign from json post' do
|
||||
post :create, campaign: campaign
|
||||
|
||||
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]
|
||||
end
|
||||
|
||||
it 'creates a campaign with a nested videolisting' do
|
||||
campaign[:videolistings_attributes] = [videolisting,]
|
||||
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.count).to eq 1
|
||||
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
|
||||
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