Skip to content

Commit

Permalink
adds integration test for campaign ended redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
phamdt committed Mar 9, 2016
1 parent f4dcea2 commit 2e275ec
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
4 changes: 4 additions & 0 deletions app/views/users/_campaign_ended.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<p class="thanks brandon">THANK YOU FOR PARTICIPATING<br>IN OUR PRE-LAUNCH.</p>
<p class="compiling brandon">WE ARE COMPILING REWARDS RIGHT NOW AND WILL EMAIL<br/>COUPON CODES TO ALL RECIPIENTS IN THE NEXT DAY OR TWO</p>
<p class="go-to brandon">In the meantime, head to <a href="http://www.harrys.com/">WWW.HARRYS.COM</a></p>
<p class="again brandon">Thank You Again!</p>
6 changes: 6 additions & 0 deletions app/views/users/_campaign_ongoing.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="key"></div>
<p class="byline brandon">Be the first to know</p>
<%= form_for @user, :url => { :action => "create" } do |f| %>
<%= f.text_field :email, :placeholder => "Enter Email", :class => "email brandon" %>
<input class="submit brandon" name="commit" type="submit" value="Step Inside" />
<% end %>
12 changes: 2 additions & 10 deletions app/views/users/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,8 @@

<div class="form-wrap clearfix <%= "ended" if Rails.application.config.ended %>">
<% if Rails.application.config.ended %>
<p class="thanks brandon">THANK YOU FOR PARTICIPATING<br>IN OUR PRE-LAUNCH.</p>
<p class="compiling brandon">WE ARE COMPILING REWARDS RIGHT NOW AND WILL EMAIL<br/>COUPON CODES TO ALL RECIPIENTS IN THE NEXT DAY OR TWO</p>
<p class="go-to brandon">In the meantime, head to <a href="http://www.harrys.com/">WWW.HARRYS.COM</a></p>
<p class="again brandon">Thank You Again!</p>
<%= render "users/campaign_ended" %>
<% else %>
<div class="key"></div>
<p class="byline brandon">Be the first to know</p>
<%= form_for @user, :url => { :action => "create" } do |f| %>
<%= f.text_field :email, :placeholder => "Enter Email", :class => "email brandon" %>
<input class="submit brandon" name="commit" type="submit" value="Step Inside" />
<% end %>
<%= render "users/campaign_ongoing" %>
<% end %>
</div>
4 changes: 4 additions & 0 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ def generate_email
end

describe UsersController, type: :controller do
before(:all) do
Rails.application.config.ended = false
end

describe 'new' do
before(:each) do
@referral_code = SecureRandom.hex(5)
Expand Down
18 changes: 18 additions & 0 deletions spec/integration/users_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'rails_helper'

describe "users", type: :request do
describe 'campaign ended' do
before(:each) do
Rails.application.config.ended = true
end

after(:each) do
Rails.application.config.ended = false
end

it 'should display campaign ended message when campaign has ended' do
get '/'
expect(response).to render_template(:partial => "_campaign_ended")
end
end
end

0 comments on commit 2e275ec

Please sign in to comment.