<%= page_title "#{Settings.event_name} Call for Presentations" %>
-
- Be part of <%= Settings.event_name %>:
- we highly encourage you to submit as many proposals as you want,
- help the authors make theirs better
- and finally select the most interesting ones for the final agenda!
- What are you waiting for?
-
+ <% if current_phase.main_text %>
+
<%= current_phase.main_text.html_safe %>
+ <% end %>
-
- You have <%= countdown_to_submissions_end %> to submit, refine and discuss proposals!
-
+ <% if current_phase.countdown_text %>
+
You have <%= countdown_to_phase_end %> <%= current_phase.countdown_text %>
+ <% end %>
<% if user_signed_in? %>
- <%= link_to "Propose a talk", new_proposal_path, :class => 'btn btn-primary' %>
+ <% if can? :create, Proposal %>
+ <%= link_to "Propose a talk", new_proposal_path, :class => 'btn btn-primary' %>
+ <% elsif @suggested_proposal && can?(:vote, @suggested_proposal) %>
+ <%= link_to "Cast your votes!", proposal_path(@suggested_proposal), :class => 'btn btn-primary' %>
+ <% end %>
<% else %>
<%= link_to 'Join the party', '#', :class => 'btn btn-primary dropdown-toggle', :data => {:toggle => 'dropdown'} %>
diff --git a/config/application.example.yml b/config/application.example.yml
index 7652e4a..4f94969 100644
--- a/config/application.example.yml
+++ b/config/application.example.yml
@@ -23,8 +23,6 @@ defaults: &defaults
mailer:
from: '"Your Event" '
bcc: 'info@example.org'
- submissions_start: '2013-03-28T00:00:00+2'
- submissions_end: '2013-04-24T00:00:00+3'
development:
<<: *defaults
diff --git a/config/application.yml b/config/application.yml
index 5033de9..449a069 100644
--- a/config/application.yml
+++ b/config/application.yml
@@ -27,8 +27,6 @@ defaults: &defaults
mailer:
from: '"EuRuKo 2013" '
bcc: 'info@euruko2013.org'
- submissions_start: '2013-03-28T00:00:00+2'
- submissions_end: '2013-04-24T00:00:00+3'
development:
<<: *defaults
diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml
index 98efb0a..004fdcc 100644
--- a/config/locales/simple_form.en.yml
+++ b/config/locales/simple_form.en.yml
@@ -31,7 +31,7 @@ en:
subscribe_to_suggestions_notifications: 'Email me for new suggestions on my proposals'
hints:
user:
- signup_reason: Tell everyone a little bit about what you are looking to get out of the event. What interests you? What doesn't interest you?
+ signup_reason: Tell everyone a little bit about what you are looking to get out of the event. What interests you? What doesn't interest you?
If you have submitted a proposal and it gets into the shortlist this info will be shown next to it during the Phase 2 of the CFP, as the "author bio".
proposal:
title: 'This is all we need from you for your suggestion. Think of something snappy.'
description: 'Tell everyone a bit more about what your talk is about. The community will help you develop this into a description of exactly what to expect from your talk.'
diff --git a/test/functional/dashboard_controller_test.rb b/test/functional/dashboard_controller_test.rb
index 441e368..f349cff 100644
--- a/test/functional/dashboard_controller_test.rb
+++ b/test/functional/dashboard_controller_test.rb
@@ -1,16 +1,113 @@
require 'test_helper'
class DashboardControllerTest < ActionController::TestCase
- setup do
- @user = FactoryGirl.create(:user)
- session[:user_id] = @user.id
- get :index
+ [Phase::ZERO].each do |phase|
+ context "During '#{phase.name}'" do
+ setup do
+ Phase.stubs(:current).returns(phase)
+ end
+
+ setup do
+ @user = FactoryGirl.create(:user)
+ session[:user_id] = @user.id
+ get :index
+ end
+
+ should respond_with :success
+
+ should assign_to(:your_proposals)
+ should_not assign_to(:proposals_you_should_look_at)
+ should_not assign_to(:proposals_that_have_changed)
+ should_not assign_to(:unvoted_proposals)
+ should_not assign_to(:proposals_that_have_been_withdrawn)
+ end
end
- should respond_with :success
+ [Phase::ONE].each do |phase|
+ context "During '#{phase.name}'" do
+ setup do
+ Phase.stubs(:current).returns(phase)
+ end
- should assign_to(:your_proposals)
- should assign_to(:proposals_you_should_look_at)
- should assign_to(:proposals_that_have_changed)
- should assign_to(:proposals_that_have_been_withdrawn)
+ setup do
+ @user = FactoryGirl.create(:user)
+ session[:user_id] = @user.id
+ get :index
+ end
+
+ should respond_with :success
+
+ should assign_to(:your_proposals)
+ should assign_to(:proposals_you_should_look_at)
+ should assign_to(:proposals_that_have_changed)
+ should assign_to(:unvoted_proposals)
+ should assign_to(:proposals_that_have_been_withdrawn)
+ end
+ end
+
+ [Phase::INTERLUDE].each do |phase|
+ context "During '#{phase.name}'" do
+ setup do
+ Phase.stubs(:current).returns(phase)
+ end
+
+ setup do
+ @user = FactoryGirl.create(:user)
+ session[:user_id] = @user.id
+ get :index
+ end
+
+ should respond_with :success
+
+ should assign_to(:your_proposals)
+ should_not assign_to(:proposals_you_should_look_at)
+ should_not assign_to(:proposals_that_have_changed)
+ should assign_to(:unvoted_proposals)
+ should assign_to(:proposals_that_have_been_withdrawn)
+ end
+ end
+
+ [Phase::TWO, Phase::CONFIRMATION].each do |phase|
+ context "During '#{phase.name}'" do
+ setup do
+ Phase.stubs(:current).returns(phase)
+ end
+
+ setup do
+ @user = FactoryGirl.create(:user)
+ session[:user_id] = @user.id
+ get :index
+ end
+
+ should respond_with :success
+
+ should assign_to(:your_proposals)
+ should_not assign_to(:proposals_you_should_look_at)
+ should_not assign_to(:proposals_that_have_changed)
+ should_not assign_to(:unvoted_proposals)
+ should assign_to(:proposals_that_have_been_withdrawn)
+ end
+ end
+
+ [Phase::LINEUP].each do |phase|
+ context "During '#{phase.name}'" do
+ setup do
+ Phase.stubs(:current).returns(phase)
+ end
+
+ setup do
+ @user = FactoryGirl.create(:user)
+ session[:user_id] = @user.id
+ get :index
+ end
+
+ should respond_with :success
+
+ should assign_to(:your_proposals)
+ should_not assign_to(:proposals_you_should_look_at)
+ should_not assign_to(:proposals_that_have_changed)
+ should_not assign_to(:unvoted_proposals)
+ should_not assign_to(:proposals_that_have_been_withdrawn)
+ end
+ end
end
\ No newline at end of file
diff --git a/test/functional/proposals_controller_test.rb b/test/functional/proposals_controller_test.rb
index 4816139..591da68 100644
--- a/test/functional/proposals_controller_test.rb
+++ b/test/functional/proposals_controller_test.rb
@@ -7,398 +7,1183 @@ def setup
@proposal = FactoryGirl.create(:proposal, :proposer => @proposer)
end
- context 'When visitor' do
- context 'on #GET to index' do
- setup do
- @withdrawn_proposal = FactoryGirl.create(:proposal, :proposer => @proposer, :withdrawn => true)
- get :index
+ context 'Before phase one' do
+ setup do
+ Phase.stubs(:current).returns(Phase::ZERO)
+ end
+
+ context 'When visitor' do
+ context 'on #GET to index' do
+ setup do
+ @withdrawn_proposal = FactoryGirl.create(:proposal, :proposer => @proposer, :withdrawn => true)
+ get :index
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposals) { [@proposal] }
+ should assign_to(:withdrawn_proposals) { [@withdrawn_proposal] }
+ should render_template('index')
end
- should respond_with(:success)
- should assign_to(:proposals) { [@proposal] }
- should assign_to(:withdrawn_proposals) { [@withdrawn_proposal] }
- should render_template('index')
- end
+ context 'on #GET to show' do
+ setup do
+ get :show, :id => @proposal.to_param
+ end
- context 'on #GET to show' do
- setup do
- get :show, :id => @proposal.to_param
+ should respond_with(:success)
+ should assign_to(:proposal) { @proposal }
+ should_not assign_to(:suggestion)
+ should render_template('show')
end
- should respond_with(:success)
- should assign_to(:proposal) { @proposal }
- should_not assign_to(:suggestion)
- should render_template('show')
- end
+ context 'on #GET to new' do
+ setup do
+ get :new
+ end
- context 'on #GET to new' do
- setup do
- get :new
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
end
- should respond_with(:redirect)
- should set_the_flash.to(/You need to sign in or sign up before continuing/)
- end
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal => FactoryGirl.attributes_for(:proposal)
+ end
- context 'on #POST to create' do
- setup do
- post :create, :proposal => FactoryGirl.attributes_for(:proposal)
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not save proposal" do
+ assert !assigns(:proposal).persisted?
+ end
end
- should respond_with(:redirect)
- should set_the_flash.to(/You need to sign in or sign up before continuing/)
+ context 'on #GET to edit' do
+ setup do
+ get :edit, :id => @proposal.to_param
+ end
- should "not save proposal" do
- assert !assigns(:proposal).persisted?
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
end
- end
- context 'on #GET to edit' do
- setup do
- get :edit, :id => @proposal.to_param
+ context 'on #PUT to update' do
+ setup do
+ put :update, :id => @proposal.to_param, :proposal => {:title => 'Title Updated'}
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not update proposal" do
+ assert_not_equal 'Title Updated', @proposal.reload.title
+ end
end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
- should set_the_flash.to(/You need to sign in or sign up before continuing/)
- end
+ context 'on #POST to withdraw' do
+ setup do
+ post :withdraw, :id => @proposal.to_param
+ end
- context 'on #PUT to update' do
- setup do
- put :update, :id => @proposal.to_param, :proposal => {:title => 'Title Updated'}
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not withdraw proposal" do
+ assert !@proposal.withdrawn?
+ end
end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
- should set_the_flash.to(/You need to sign in or sign up before continuing/)
+ context 'on #POST to republish' do
+ setup do
+ @proposal.withdraw!
+ post :republish, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not republish proposal" do
+ assert @proposal.withdrawn?
+ end
+ end
- should "not update proposal" do
- assert_not_equal 'Title Updated', @proposal.reload.title
+ context 'on #POST to vote' do
+ [:up, :down, :clear].each do |vote|
+ context "with :#{vote}" do
+ setup do
+ post :vote, :id => @proposal.to_param, :vote => vote.to_s
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not count a vote" do
+ assert_equal 0, @proposal.votes_for
+ assert_equal 0, @proposal.votes_against
+ end
+ end
+ end
end
end
- context 'on #POST to withdraw' do
+ context 'When viewer is logged in' do
setup do
- post :withdraw, :id => @proposal.to_param
+ session[:user_id] = @viewer.id
end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
- should set_the_flash.to(/You need to sign in or sign up before continuing/)
+ context 'on #GET to index' do
+ setup do
+ get :index
+ end
- should "not withdraw proposal" do
- assert !@proposal.withdrawn?
+ should respond_with(:success)
+ should assign_to(:proposals) { [@proposal] }
+ should assign_to(:withdrawn_proposals) { [@withdrawn_proposal] }
+ should render_template('index')
end
- end
- context 'on #POST to republish' do
- setup do
- @proposal.withdraw!
- post :republish, :id => @proposal.to_param
+ context 'on #GET to show' do
+ setup do
+ get :show, :id => @proposal.to_param
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposal) { @proposal }
+ should_not assign_to(:suggestion)
+ should render_template('show')
end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
- should set_the_flash.to(/You need to sign in or sign up before continuing/)
+ context 'on #GET to new' do
+ setup do
+ get :new
+ end
- should "not republish proposal" do
- assert @proposal.withdrawn?
+ should respond_with(:redirect)
end
- end
- context 'on #POST to vote' do
- [:up, :down, :clear].each do |vote|
- context "with :#{vote}" do
- setup do
- post :vote, :id => @proposal.to_param, :vote => vote.to_s
- end
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal => FactoryGirl.attributes_for(:proposal)
+ end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
- should set_the_flash.to(/You need to sign in or sign up before continuing/)
+ should respond_with(:redirect)
- should "not count a vote" do
- assert_equal 0, @proposal.votes_for
- assert_equal 0, @proposal.votes_against
- end
+ should "not save proposal" do
+ assert !assigns(:proposal).persisted?
+ end
+
+ should "not send email" do
+ assert ActionMailer::Base.deliveries.empty?
end
end
- end
- end
- context 'When viewer is logged in' do
- setup do
- session[:user_id] = @viewer.id
- end
+ context 'on #GET to edit' do
+ setup do
+ get :edit, :id => @proposal.to_param
+ end
- context 'on #GET to index' do
- setup do
- get :index
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
end
- should respond_with(:success)
- should assign_to(:proposals) { [@proposal] }
- should assign_to(:withdrawn_proposals) { [@withdrawn_proposal] }
- should render_template('index')
- end
+ context 'on #PUT to update' do
+ setup do
+ put :update, :id => @proposal.to_param, :proposal => {:title => 'Title Updated'}
+ end
- context 'on #GET to show' do
- setup do
- get :show, :id => @proposal.to_param
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not update proposal" do
+ assert_not_equal 'Title Updated', @proposal.reload.title
+ end
end
- should respond_with(:success)
- should assign_to(:proposal) { @proposal }
- should assign_to(:suggestion)
- should render_template('show')
- end
+ context 'on #POST to withdraw' do
+ setup do
+ post :withdraw, :id => @proposal.to_param
+ end
- context 'on #GET to new' do
- setup do
- get :new
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not withdraw proposal" do
+ assert !@proposal.withdrawn?
+ end
end
- should respond_with(:success)
- should render_template('new')
- end
+ context 'on #POST to republish' do
+ setup do
+ @proposal.withdraw!
+ post :republish, :id => @proposal.to_param
+ end
- context 'on #POST to create' do
- setup do
- post :create, :proposal => FactoryGirl.attributes_for(:proposal)
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not republish proposal" do
+ assert @proposal.withdrawn?
+ end
end
- should respond_with(:redirect)
+ context 'on #POST to vote' do
+ context "with :up" do
+ setup do
+ post :vote, :id => @proposal.to_param, :vote => 'up'
+ end
- should "save proposal" do
- assert assigns(:proposal).persisted?
- end
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
- should "assign proposal to user" do
- assert_equal @viewer, assigns(:proposal).proposer
- end
+ should "not count an upvote" do
+ assert_equal 0, @proposal.votes_for
+ end
- should "send email" do
- assert !ActionMailer::Base.deliveries.empty?
- end
- end
+ should "not count a downvote" do
+ assert_equal 0, @proposal.votes_against
+ end
+ end
- context 'on #GET to edit' do
- setup do
- get :edit, :id => @proposal.to_param
- end
+ context "with :down" do
+ setup do
+ post :vote, :id => @proposal.to_param, :vote => 'down'
+ end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
- should set_the_flash.to(/You are not authorized to access this page/)
- end
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
- context 'on #PUT to update' do
- setup do
- put :update, :id => @proposal.to_param, :proposal => {:title => 'Title Updated'}
- end
+ should "not count an downvote" do
+ assert_equal 0, @proposal.votes_for
+ end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
- should set_the_flash.to(/You are not authorized to access this page/)
+ should "count a downvote" do
+ assert_equal 0, @proposal.votes_against
+ end
+ end
+
+ context "with :clear" do
+ setup do
+ @viewer.vote_for(@proposal)
+ post :vote, :id => @proposal.to_param, :vote => 'clear'
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
- should "not update proposal" do
- assert_not_equal 'Title Updated', @proposal.reload.title
+ should "not neutralize votes" do
+ assert_equal 1, @proposal.votes_for
+ assert_equal 0, @proposal.votes_against
+ end
+ end
end
end
- context 'on #POST to withdraw' do
+ context 'When proposer is logged in' do
setup do
- post :withdraw, :id => @proposal.to_param
+ session[:user_id] = @proposer.id
end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
- should set_the_flash.to(/You are not authorized to access this page/)
+ context 'on #GET to index' do
+ setup do
+ get :index
+ end
- should "not withdraw proposal" do
- assert !@proposal.withdrawn?
+ should respond_with(:success)
+ should assign_to(:proposals) { [@proposal] }
+ should assign_to(:withdrawn_proposals) { [@withdrawn_proposal] }
+ should render_template('index')
end
- end
- context 'on #POST to republish' do
- setup do
- @proposal.withdraw!
- post :republish, :id => @proposal.to_param
+ context 'on #GET to show' do
+ setup do
+ get :show, :id => @proposal.to_param
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposal) { @proposal }
+ should_not assign_to(:suggestion)
+ should render_template('show')
end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
- should set_the_flash.to(/You are not authorized to access this page/)
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal => FactoryGirl.attributes_for(:proposal)
+ end
+
+ should respond_with(:redirect)
- should "not republish proposal" do
- assert @proposal.withdrawn?
+ should "not save proposal" do
+ assert !assigns(:proposal).persisted?
+ end
end
- end
- context 'on #POST to vote' do
- context "with :up" do
+ context 'on #GET to edit' do
setup do
- post :vote, :id => @proposal.to_param, :vote => 'up'
+ get :edit, :id => @proposal.to_param
end
should assign_to(:proposal) { @proposal }
should respond_with(:redirect)
- should set_the_flash.to(/Thank you for casting your vote. Your vote has been captured!/)
+ end
- should "count an upvote" do
- assert_equal 1, @proposal.votes_for
+ context 'on #PUT to update' do
+ setup do
+ put :update, :id => @proposal.to_param, :proposal => {:title => 'Title Updated'}
end
- should "not count a downvote" do
- assert_equal 0, @proposal.votes_against
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+
+ should "update proposal" do
+ assert_not_equal 'Title Updated', @proposal.reload.title
end
end
- context "with :down" do
+ context 'on #POST to withdraw' do
setup do
- post :vote, :id => @proposal.to_param, :vote => 'down'
+ post :withdraw, :id => @proposal.to_param
end
should assign_to(:proposal) { @proposal }
should respond_with(:redirect)
- should set_the_flash.to(/Thank you for casting your vote. Your vote has been captured!/)
-
- should "not count an downvote" do
- assert_equal 0, @proposal.votes_for
- end
- should "count a downvote" do
- assert_equal 1, @proposal.votes_against
+ should "not withdraw proposal" do
+ assert !@proposal.reload.withdrawn?
end
end
- context "with :clear" do
+ context 'on #POST to republish' do
setup do
- @viewer.vote_for(@proposal)
- post :vote, :id => @proposal.to_param, :vote => 'clear'
+ @proposal.withdraw!
+ post :republish, :id => @proposal.to_param
end
should assign_to(:proposal) { @proposal }
should respond_with(:redirect)
- should set_the_flash.to('Your vote has been cleared. Remember to come back to vote again once you are sure!')
- should "neutralize votes" do
- assert_equal 0, @proposal.votes_for
- assert_equal 0, @proposal.votes_against
+ should "republish proposal" do
+ assert @proposal.reload.withdrawn?
+ end
+ end
+
+ context 'on #POST to vote' do
+ [:up, :down, :clear].each do |vote|
+ context "with :#{vote}" do
+ setup do
+ post :vote, :id => @proposal.to_param, :vote => vote.to_s
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not count a vote" do
+ assert_equal 0, @proposal.votes_for
+ assert_equal 0, @proposal.votes_against
+ end
+ end
end
end
end
end
- context 'When proposer is logged in' do
+ context 'During phase one' do
setup do
- session[:user_id] = @proposer.id
+ Phase.stubs(:current).returns(Phase::ONE)
end
- context 'on #GET to index' do
- setup do
- get :index
+ context 'When visitor' do
+ context 'on #GET to index' do
+ setup do
+ @withdrawn_proposal = FactoryGirl.create(:proposal, :proposer => @proposer, :withdrawn => true)
+ get :index
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposals) { [@proposal] }
+ should assign_to(:withdrawn_proposals) { [@withdrawn_proposal] }
+ should render_template('index')
end
- should respond_with(:success)
- should assign_to(:proposals) { [@proposal] }
- should assign_to(:withdrawn_proposals) { [@withdrawn_proposal] }
- should render_template('index')
- end
+ context 'on #GET to show' do
+ setup do
+ get :show, :id => @proposal.to_param
+ end
- context 'on #GET to show' do
- setup do
- get :show, :id => @proposal.to_param
+ should respond_with(:success)
+ should assign_to(:proposal) { @proposal }
+ should_not assign_to(:suggestion)
+ should render_template('show')
end
- should respond_with(:success)
- should assign_to(:proposal) { @proposal }
- should assign_to(:suggestion)
- should render_template('show')
- end
+ context 'on #GET to new' do
+ setup do
+ get :new
+ end
- context 'on #POST to create' do
- setup do
- post :create, :proposal => FactoryGirl.attributes_for(:proposal)
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
end
- should respond_with(:redirect)
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal => FactoryGirl.attributes_for(:proposal)
+ end
+
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
- should "save proposal" do
- assert assigns(:proposal).persisted?
+ should "not save proposal" do
+ assert !assigns(:proposal).persisted?
+ end
end
- should "assign proposal to user" do
- assert_equal @proposer, assigns(:proposal).proposer
+ context 'on #GET to edit' do
+ setup do
+ get :edit, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
end
- end
- context 'on #GET to edit' do
- setup do
- get :edit, :id => @proposal.to_param
+ context 'on #PUT to update' do
+ setup do
+ put :update, :id => @proposal.to_param, :proposal => {:title => 'Title Updated'}
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not update proposal" do
+ assert_not_equal 'Title Updated', @proposal.reload.title
+ end
end
- should assign_to(:proposal) { @proposal }
- should respond_with(:success)
- should render_template('edit')
- end
+ context 'on #POST to withdraw' do
+ setup do
+ post :withdraw, :id => @proposal.to_param
+ end
- context 'on #PUT to update' do
- setup do
- put :update, :id => @proposal.to_param, :proposal => {:title => 'Title Updated'}
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not withdraw proposal" do
+ assert !@proposal.withdrawn?
+ end
end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
+ context 'on #POST to republish' do
+ setup do
+ @proposal.withdraw!
+ post :republish, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not republish proposal" do
+ assert @proposal.withdrawn?
+ end
+ end
- should "update proposal" do
- assert_equal 'Title Updated', @proposal.reload.title
+ context 'on #POST to vote' do
+ [:up, :down, :clear].each do |vote|
+ context "with :#{vote}" do
+ setup do
+ post :vote, :id => @proposal.to_param, :vote => vote.to_s
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not count a vote" do
+ assert_equal 0, @proposal.votes_for
+ assert_equal 0, @proposal.votes_against
+ end
+ end
+ end
end
end
- context 'on #POST to withdraw' do
+ context 'When viewer is logged in' do
setup do
- post :withdraw, :id => @proposal.to_param
+ session[:user_id] = @viewer.id
end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
- should set_the_flash.to(/Your proposal has been withdrawn/)
+ context 'on #GET to index' do
+ setup do
+ get :index
+ end
- should "withdraw proposal" do
- assert @proposal.reload.withdrawn?
+ should respond_with(:success)
+ should assign_to(:proposals) { [@proposal] }
+ should assign_to(:withdrawn_proposals) { [@withdrawn_proposal] }
+ should render_template('index')
end
- end
- context 'on #POST to republish' do
- setup do
- @proposal.withdraw!
- post :republish, :id => @proposal.to_param
+ context 'on #GET to show' do
+ setup do
+ get :show, :id => @proposal.to_param
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should render_template('show')
end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
- should set_the_flash.to(/Your proposal has been republished/)
+ context 'on #GET to new' do
+ setup do
+ get :new
+ end
- should "republish proposal" do
- assert !@proposal.reload.withdrawn?
+ should respond_with(:success)
+ should render_template('new')
end
- end
- context 'on #POST to vote' do
- [:up, :down, :clear].each do |vote|
- context "with :#{vote}" do
- setup do
- post :vote, :id => @proposal.to_param, :vote => vote.to_s
- end
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal => FactoryGirl.attributes_for(:proposal)
+ end
- should assign_to(:proposal) { @proposal }
- should respond_with(:redirect)
- should set_the_flash.to(/You are not authorized to access this page/)
+ should respond_with(:redirect)
- should "not count a vote" do
- assert_equal 0, @proposal.votes_for
- assert_equal 0, @proposal.votes_against
+ should "save proposal" do
+ assert assigns(:proposal).persisted?
+ end
+
+ should "assign proposal to user" do
+ assert_equal @viewer, assigns(:proposal).proposer
+ end
+
+ should "send email" do
+ assert !ActionMailer::Base.deliveries.empty?
+ end
+ end
+
+ context 'on #GET to edit' do
+ setup do
+ get :edit, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+ end
+
+ context 'on #PUT to update' do
+ setup do
+ put :update, :id => @proposal.to_param, :proposal => {:title => 'Title Updated'}
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not update proposal" do
+ assert_not_equal 'Title Updated', @proposal.reload.title
+ end
+ end
+
+ context 'on #POST to withdraw' do
+ setup do
+ post :withdraw, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not withdraw proposal" do
+ assert !@proposal.withdrawn?
+ end
+ end
+
+ context 'on #POST to republish' do
+ setup do
+ @proposal.withdraw!
+ post :republish, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not republish proposal" do
+ assert @proposal.withdrawn?
+ end
+ end
+
+ context 'on #POST to vote' do
+ context "with :up" do
+ setup do
+ post :vote, :id => @proposal.to_param, :vote => 'up'
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/Thank you for casting your vote. Your vote has been captured!/)
+
+ should "count an upvote" do
+ assert_equal 1, @proposal.votes_for
+ end
+
+ should "not count a downvote" do
+ assert_equal 0, @proposal.votes_against
+ end
+ end
+
+ context "with :down" do
+ setup do
+ post :vote, :id => @proposal.to_param, :vote => 'down'
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/Thank you for casting your vote. Your vote has been captured!/)
+
+ should "not count an downvote" do
+ assert_equal 0, @proposal.votes_for
+ end
+
+ should "count a downvote" do
+ assert_equal 1, @proposal.votes_against
+ end
+ end
+
+ context "with :clear" do
+ setup do
+ @viewer.vote_for(@proposal)
+ post :vote, :id => @proposal.to_param, :vote => 'clear'
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to('Your vote has been cleared. Remember to come back to vote again once you are sure!')
+
+ should "neutralize votes" do
+ assert_equal 0, @proposal.votes_for
+ assert_equal 0, @proposal.votes_against
+ end
+ end
+ end
+ end
+
+ context 'When proposer is logged in' do
+ setup do
+ session[:user_id] = @proposer.id
+ end
+
+ context 'on #GET to index' do
+ setup do
+ get :index
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposals) { [@proposal] }
+ should assign_to(:withdrawn_proposals) { [@withdrawn_proposal] }
+ should render_template('index')
+ end
+
+ context 'on #GET to show' do
+ setup do
+ get :show, :id => @proposal.to_param
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should render_template('show')
+ end
+
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal => FactoryGirl.attributes_for(:proposal)
+ end
+
+ should respond_with(:redirect)
+
+ should "save proposal" do
+ assert assigns(:proposal).persisted?
+ end
+
+ should "assign proposal to user" do
+ assert_equal @proposer, assigns(:proposal).proposer
+ end
+ end
+
+ context 'on #GET to edit' do
+ setup do
+ get :edit, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:success)
+ should render_template('edit')
+ end
+
+ context 'on #PUT to update' do
+ setup do
+ put :update, :id => @proposal.to_param, :proposal => {:title => 'Title Updated'}
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+
+ should "update proposal" do
+ assert_equal 'Title Updated', @proposal.reload.title
+ end
+ end
+
+ context 'on #POST to withdraw' do
+ setup do
+ post :withdraw, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/Your proposal has been withdrawn/)
+
+ should "withdraw proposal" do
+ assert @proposal.reload.withdrawn?
+ end
+ end
+
+ context 'on #POST to republish' do
+ setup do
+ @proposal.withdraw!
+ post :republish, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/Your proposal has been republished/)
+
+ should "republish proposal" do
+ assert !@proposal.reload.withdrawn?
+ end
+ end
+
+ context 'on #POST to vote' do
+ [:up, :down, :clear].each do |vote|
+ context "with :#{vote}" do
+ setup do
+ post :vote, :id => @proposal.to_param, :vote => vote.to_s
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not count a vote" do
+ assert_equal 0, @proposal.votes_for
+ assert_equal 0, @proposal.votes_against
+ end
+ end
+ end
+ end
+ end
+ end
+
+ context 'During interlude' do
+ setup do
+ Phase.stubs(:current).returns(Phase::INTERLUDE)
+ end
+
+ context 'When visitor' do
+ context 'on #GET to index' do
+ setup do
+ @withdrawn_proposal = FactoryGirl.create(:proposal, :proposer => @proposer, :withdrawn => true)
+ get :index
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposals) { [@proposal] }
+ should assign_to(:withdrawn_proposals) { [@withdrawn_proposal] }
+ should render_template('index')
+ end
+
+ context 'on #GET to show' do
+ setup do
+ get :show, :id => @proposal.to_param
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposal) { @proposal }
+ should_not assign_to(:suggestion)
+ should render_template('show')
+ end
+
+ context 'on #GET to new' do
+ setup do
+ get :new
+ end
+
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+ end
+
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal => FactoryGirl.attributes_for(:proposal)
+ end
+
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not save proposal" do
+ assert !assigns(:proposal).persisted?
+ end
+ end
+
+ context 'on #GET to edit' do
+ setup do
+ get :edit, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+ end
+
+ context 'on #PUT to update' do
+ setup do
+ put :update, :id => @proposal.to_param, :proposal => {:title => 'Title Updated'}
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not update proposal" do
+ assert_not_equal 'Title Updated', @proposal.reload.title
+ end
+ end
+
+ context 'on #POST to withdraw' do
+ setup do
+ post :withdraw, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not withdraw proposal" do
+ assert !@proposal.withdrawn?
+ end
+ end
+
+ context 'on #POST to republish' do
+ setup do
+ @proposal.withdraw!
+ post :republish, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not republish proposal" do
+ assert @proposal.withdrawn?
+ end
+ end
+
+ context 'on #POST to vote' do
+ [:up, :down, :clear].each do |vote|
+ context "with :#{vote}" do
+ setup do
+ post :vote, :id => @proposal.to_param, :vote => vote.to_s
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "not count a vote" do
+ assert_equal 0, @proposal.votes_for
+ assert_equal 0, @proposal.votes_against
+ end
+ end
+ end
+ end
+ end
+
+ context 'When viewer is logged in' do
+ setup do
+ session[:user_id] = @viewer.id
+ end
+
+ context 'on #GET to index' do
+ setup do
+ get :index
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposals) { [@proposal] }
+ should assign_to(:withdrawn_proposals) { [@withdrawn_proposal] }
+ should render_template('index')
+ end
+
+ context 'on #GET to show' do
+ setup do
+ get :show, :id => @proposal.to_param
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposal) { @proposal }
+ should_not assign_to(:suggestion)
+ should render_template('show')
+ end
+
+ context 'on #GET to new' do
+ setup do
+ get :new
+ end
+
+ should respond_with(:redirect)
+ end
+
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal => FactoryGirl.attributes_for(:proposal)
+ end
+
+ should respond_with(:redirect)
+
+ should "not save proposal" do
+ assert !assigns(:proposal).persisted?
+ end
+ end
+
+ context 'on #GET to edit' do
+ setup do
+ get :edit, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+ end
+
+ context 'on #PUT to update' do
+ setup do
+ put :update, :id => @proposal.to_param, :proposal => {:title => 'Title Updated'}
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not update proposal" do
+ assert_not_equal 'Title Updated', @proposal.reload.title
+ end
+ end
+
+ context 'on #POST to withdraw' do
+ setup do
+ post :withdraw, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not withdraw proposal" do
+ assert !@proposal.withdrawn?
+ end
+ end
+
+ context 'on #POST to republish' do
+ setup do
+ @proposal.withdraw!
+ post :republish, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not republish proposal" do
+ assert @proposal.withdrawn?
+ end
+ end
+
+ context 'on #POST to vote' do
+ context "with :up" do
+ setup do
+ post :vote, :id => @proposal.to_param, :vote => 'up'
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/Thank you for casting your vote. Your vote has been captured!/)
+
+ should "count an upvote" do
+ assert_equal 1, @proposal.votes_for
+ end
+
+ should "not count a downvote" do
+ assert_equal 0, @proposal.votes_against
+ end
+ end
+
+ context "with :down" do
+ setup do
+ post :vote, :id => @proposal.to_param, :vote => 'down'
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/Thank you for casting your vote. Your vote has been captured!/)
+
+ should "not count an downvote" do
+ assert_equal 0, @proposal.votes_for
+ end
+
+ should "count a downvote" do
+ assert_equal 1, @proposal.votes_against
+ end
+ end
+
+ context "with :clear" do
+ setup do
+ @viewer.vote_for(@proposal)
+ post :vote, :id => @proposal.to_param, :vote => 'clear'
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to('Your vote has been cleared. Remember to come back to vote again once you are sure!')
+
+ should "neutralize votes" do
+ assert_equal 0, @proposal.votes_for
+ assert_equal 0, @proposal.votes_against
+ end
+ end
+ end
+ end
+
+ context 'When proposer is logged in' do
+ setup do
+ session[:user_id] = @proposer.id
+ end
+
+ context 'on #GET to index' do
+ setup do
+ get :index
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposals) { [@proposal] }
+ should assign_to(:withdrawn_proposals) { [@withdrawn_proposal] }
+ should render_template('index')
+ end
+
+ context 'on #GET to show' do
+ setup do
+ get :show, :id => @proposal.to_param
+ end
+
+ should respond_with(:success)
+ should assign_to(:proposal) { @proposal }
+ should_not assign_to(:suggestion)
+ should render_template('show')
+ end
+
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal => FactoryGirl.attributes_for(:proposal)
+ end
+
+ should respond_with(:redirect)
+
+ should "not save proposal" do
+ assert !assigns(:proposal).persisted?
+ end
+ end
+
+ context 'on #GET to edit' do
+ setup do
+ get :edit, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ end
+
+ context 'on #PUT to update' do
+ setup do
+ put :update, :id => @proposal.to_param, :proposal => {:title => 'Title Updated'}
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+
+ should "not update proposal" do
+ assert_not_equal 'Title Updated', @proposal.reload.title
+ end
+ end
+
+ context 'on #POST to withdraw' do
+ setup do
+ post :withdraw, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/Your proposal has been withdrawn/)
+
+ should "withdraw proposal" do
+ assert @proposal.reload.withdrawn?
+ end
+ end
+
+ context 'on #POST to republish' do
+ setup do
+ @proposal.withdraw!
+ post :republish, :id => @proposal.to_param
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/Your proposal has been republished/)
+
+ should "republish proposal" do
+ assert !@proposal.reload.withdrawn?
+ end
+ end
+
+ context 'on #POST to vote' do
+ [:up, :down, :clear].each do |vote|
+ context "with :#{vote}" do
+ setup do
+ post :vote, :id => @proposal.to_param, :vote => vote.to_s
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not count a vote" do
+ assert_equal 0, @proposal.votes_for
+ assert_equal 0, @proposal.votes_against
+ end
end
end
end
diff --git a/test/functional/suggestions_controller_test.rb b/test/functional/suggestions_controller_test.rb
index 4200a46..7df343c 100644
--- a/test/functional/suggestions_controller_test.rb
+++ b/test/functional/suggestions_controller_test.rb
@@ -7,124 +7,71 @@ def setup
@proposal = FactoryGirl.create(:proposal, :proposer => @proposer)
end
- context 'When visitor' do
- context 'on #POST to create' do
- setup do
- post :create, :proposal_id => @proposal.to_param, :suggestion => FactoryGirl.attributes_for(:suggestion)
- end
-
- should assign_to(:proposal) { @proposal }
- should assign_to(:suggestion)
- should respond_with(:redirect)
- should set_the_flash.to(/You need to sign in or sign up before continuing/)
-
- should "save suggestion" do
- assert !assigns(:suggestion).persisted?
- end
- end
-
- context 'on #POST to update' do
- setup do
- @suggestion = FactoryGirl.create(:suggestion)
- put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
- end
-
- should assign_to(:proposal) { @proposal }
- should assign_to(:suggestion)
- should respond_with(:redirect)
- should set_the_flash.to(/You need to sign in or sign up before continuing/)
-
- should "not update suggestion" do
- assert_equal 1, @suggestion.versions.size
- end
- end
- end
-
- context 'When viewer' do
+ context 'During phase one' do
setup do
- session[:user_id] = @viewer.id
+ Phase.stubs(:current).returns(Phase::ONE)
end
- context 'on #POST to create' do
- setup do
- post :create, :proposal_id => @proposal.to_param, :suggestion => FactoryGirl.attributes_for(:suggestion)
- end
-
- should assign_to(:proposal) { @proposal }
- should assign_to(:suggestion)
- should respond_with(:redirect)
- should set_the_flash.to(/Your suggestion has been published/)
+ context 'When visitor' do
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal_id => @proposal.to_param, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
- should "save suggestion" do
- assert assigns(:suggestion).persisted?
- end
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
- should "send email" do
- assert !ActionMailer::Base.deliveries.empty?
+ should "save suggestion" do
+ assert !assigns(:suggestion).persisted?
+ end
end
- end
- context 'on #POST to update' do
- setup do
- @suggestion = FactoryGirl.create(:suggestion, :author => @viewer)
- put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
- end
+ context 'on #POST to update' do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion)
+ put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
- should assign_to(:proposal) { @proposal }
- should assign_to(:suggestion)
- should respond_with(:redirect)
- should set_the_flash.to(/You are not authorized to access this page/)
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
- should "not update suggestion" do
- assert_equal 1, @suggestion.versions.size
+ should "not update suggestion" do
+ assert_equal 1, @suggestion.versions.size
+ end
end
end
- end
-
- context 'When proposer' do
- setup do
- session[:user_id] = @proposer.id
- end
- context 'on #POST to create' do
+ context 'When viewer' do
setup do
- post :create, :proposal_id => @proposal.to_param, :suggestion => FactoryGirl.attributes_for(:suggestion)
- end
-
- should assign_to(:proposal) { @proposal }
- should assign_to(:suggestion)
- should respond_with(:redirect)
- should set_the_flash.to(/Your suggestion has been published/)
-
- should "save suggestion" do
- assert assigns(:suggestion).persisted?
+ session[:user_id] = @viewer.id
end
- should "send email" do
- assert !ActionMailer::Base.deliveries.empty?
- end
- end
-
- context 'on #POST to update' do
- context 'own suggestion' do
+ context 'on #POST to create' do
setup do
- @suggestion = FactoryGirl.create(:suggestion, :author => @proposer)
- put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ post :create, :proposal_id => @proposal.to_param, :suggestion => FactoryGirl.attributes_for(:suggestion)
end
should assign_to(:proposal) { @proposal }
should assign_to(:suggestion)
should respond_with(:redirect)
- should set_the_flash.to(/You are not authorized to access this page/)
+ should set_the_flash.to(/Your suggestion has been published/)
- should "not update suggestion" do
- assert_equal 1, @suggestion.versions.size
+ should "save suggestion" do
+ assert assigns(:suggestion).persisted?
+ end
+
+ should "send email" do
+ assert !ActionMailer::Base.deliveries.empty?
end
end
- context 'someone else suggestion' do
+ context 'on #POST to update' do
setup do
- @suggestion = FactoryGirl.create(:suggestion)
+ @suggestion = FactoryGirl.create(:suggestion, :author => @viewer)
put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
end
@@ -138,28 +85,24 @@ def setup
end
end
end
- end
- context 'When moderator' do
- setup do
- @moderator = FactoryGirl.create(:user, :email => 'moderator@euruko2013.org')
- session[:user_id] = @moderator
- end
+ context 'When proposer' do
+ setup do
+ session[:user_id] = @proposer.id
+ end
- context 'on #POST to update' do
- context 'own suggestion' do
+ context 'on #POST to create' do
setup do
- @suggestion = FactoryGirl.create(:suggestion, :author => @moderator)
- put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ post :create, :proposal_id => @proposal.to_param, :suggestion => FactoryGirl.attributes_for(:suggestion)
end
should assign_to(:proposal) { @proposal }
should assign_to(:suggestion)
should respond_with(:redirect)
- should set_the_flash.to(/Suggestion has been updated/)
+ should set_the_flash.to(/Your suggestion has been published/)
- should "update suggestion" do
- assert_equal 2, @suggestion.versions.size
+ should "save suggestion" do
+ assert assigns(:suggestion).persisted?
end
should "send email" do
@@ -167,26 +110,269 @@ def setup
end
end
- context 'someone else suggestion' do
- setup do
- @suggestion = FactoryGirl.create(:suggestion)
- put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ context 'on #POST to update' do
+ context 'own suggestion' do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion, :author => @proposer)
+ put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not update suggestion" do
+ assert_equal 1, @suggestion.versions.size
+ end
end
- should assign_to(:proposal) { @proposal }
- should assign_to(:suggestion)
- should respond_with(:redirect)
- should set_the_flash.to(/Suggestion has been updated/)
+ context 'someone else suggestion' do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion)
+ put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
- should "update suggestion" do
- assert_equal 2, @suggestion.versions.size
+ should "not update suggestion" do
+ assert_equal 1, @suggestion.versions.size
+ end
end
+ end
+ end
- should "send email" do
- assert !ActionMailer::Base.deliveries.empty?
+ context 'When moderator' do
+ setup do
+ @moderator = FactoryGirl.create(:user, :email => 'moderator@euruko2013.org')
+ session[:user_id] = @moderator
+ end
+
+ context 'on #POST to update' do
+ context 'own suggestion' do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion, :author => @moderator)
+ put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/Suggestion has been updated/)
+
+ should "update suggestion" do
+ assert_equal 2, @suggestion.versions.size
+ end
+
+ should "send email" do
+ assert !ActionMailer::Base.deliveries.empty?
+ end
+ end
+
+ context 'someone else suggestion' do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion)
+ put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/Suggestion has been updated/)
+
+ should "update suggestion" do
+ assert_equal 2, @suggestion.versions.size
+ end
+
+ should "send email" do
+ assert !ActionMailer::Base.deliveries.empty?
+ end
end
end
+
end
+ end
+
+ [Phase.all - [Phase::ONE]].flatten.each do |phase|
+ context "During '#{phase.name}'" do
+ setup do
+ Phase.stubs(:current).returns(phase)
+ end
+
+ context 'When visitor' do
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal_id => @proposal.to_param, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+
+ should "save suggestion" do
+ assert !assigns(:suggestion).persisted?
+ end
+ end
+
+ context 'on #POST to update' do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion)
+ put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/You need to sign in or sign up before continuing/)
+ should "not update suggestion" do
+ assert_equal 1, @suggestion.versions.size
+ end
+ end
+ end
+
+ context 'When viewer' do
+ setup do
+ session[:user_id] = @viewer.id
+ end
+
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal_id => @proposal.to_param, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+
+ should "not save suggestion" do
+ assert !assigns(:suggestion).persisted?
+ end
+ end
+
+ context 'on #POST to update' do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion, :author => @viewer)
+ put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not update suggestion" do
+ assert_equal 1, @suggestion.versions.size
+ end
+ end
+ end
+
+ context 'When proposer' do
+ setup do
+ session[:user_id] = @proposer.id
+ end
+
+ context 'on #POST to create' do
+ setup do
+ post :create, :proposal_id => @proposal.to_param, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+
+ should "not save suggestion" do
+ assert !assigns(:suggestion).persisted?
+ end
+ end
+
+ context 'on #POST to update' do
+ context 'own suggestion' do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion, :author => @proposer)
+ put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not update suggestion" do
+ assert_equal 1, @suggestion.versions.size
+ end
+ end
+
+ context 'someone else suggestion' do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion)
+ put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/You are not authorized to access this page/)
+
+ should "not update suggestion" do
+ assert_equal 1, @suggestion.versions.size
+ end
+ end
+ end
+ end
+
+ context 'When moderator' do
+ setup do
+ @moderator = FactoryGirl.create(:user, :email => 'moderator@euruko2013.org')
+ session[:user_id] = @moderator
+ end
+
+ context 'on #POST to update' do
+ context 'own suggestion' do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion, :author => @moderator)
+ put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/Suggestion has been updated/)
+
+ should "update suggestion" do
+ assert_equal 2, @suggestion.versions.size
+ end
+
+ should "send email" do
+ assert !ActionMailer::Base.deliveries.empty?
+ end
+ end
+
+ context 'someone else suggestion' do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion)
+ put :update, :proposal_id => @proposal.to_param, :id => @suggestion.id, :suggestion => FactoryGirl.attributes_for(:suggestion)
+ end
+
+ should assign_to(:proposal) { @proposal }
+ should assign_to(:suggestion)
+ should respond_with(:redirect)
+ should set_the_flash.to(/Suggestion has been updated/)
+
+ should "update suggestion" do
+ assert_equal 2, @suggestion.versions.size
+ end
+
+ should "send email" do
+ assert !ActionMailer::Base.deliveries.empty?
+ end
+ end
+ end
+ end
+ end
end
end
\ No newline at end of file
diff --git a/test/integration/dashboard_test.rb b/test/integration/dashboard_test.rb
index 6b969e6..adc3570 100644
--- a/test/integration/dashboard_test.rb
+++ b/test/integration/dashboard_test.rb
@@ -1,187 +1,258 @@
require "test_helper"
class DashboardTest < IntegrationTestCase
-
- context "Given a bunch of proposals with varying amounts of feedback" do
+ context "During phase one" do
setup do
- @me = FactoryGirl.create(:user)
+ Phase.stubs(:current).returns(Phase::ONE)
+ end
- @proposal1 = FactoryGirl.create(:proposal)
- @proposal2 = FactoryGirl.create(:proposal)
- @proposal3 = FactoryGirl.create(:proposal)
+ context "given a bunch of proposals with varying amounts of feedback" do
+ setup do
+ @me = FactoryGirl.create(:user)
- @withdrawn_proposal = FactoryGirl.create(:proposal, withdrawn: true)
+ @proposal1 = FactoryGirl.create(:proposal)
+ @proposal2 = FactoryGirl.create(:proposal)
+ @proposal3 = FactoryGirl.create(:proposal)
- @my_proposal = FactoryGirl.create(:proposal, :proposer => @me)
+ @withdrawn_proposal = FactoryGirl.create(:proposal, withdrawn: true)
- FactoryGirl.create(:suggestion, :proposal => @proposal2)
- FactoryGirl.create(:suggestion, :proposal => @proposal2)
- FactoryGirl.create(:suggestion, :proposal => @proposal2)
+ @my_proposal = FactoryGirl.create(:proposal, :proposer => @me)
- FactoryGirl.create(:suggestion, :proposal => @proposal1)
- end
+ FactoryGirl.create(:suggestion, :proposal => @proposal2)
+ FactoryGirl.create(:suggestion, :proposal => @proposal2)
+ FactoryGirl.create(:suggestion, :proposal => @proposal2)
- context "When I visit my dashboard" do
- setup do
- sign_in @me
- visit "/dashboard"
+ FactoryGirl.create(:suggestion, :proposal => @proposal1)
end
- should "see a list of proposals I made" do
- within('#your-proposals') do
- assert page.has_content?(@my_proposal.title), "proposal was missing"
- end
- end
-
- context "and some new suggestions have been made for one of my proposals" do
+ context "When I visit my dashboard" do
setup do
- Timecop.travel 5.minutes.from_now
- FactoryGirl.create(:suggestion, :proposal => @my_proposal)
- FactoryGirl.create(:suggestion, :proposal => @my_proposal, :author => @me)
- Timecop.travel 5.minutes.from_now
- FactoryGirl.create(:suggestion, :proposal => @my_proposal)
- FactoryGirl.create(:suggestion, :proposal => @my_proposal)
+ sign_in @me
visit "/dashboard"
end
- should "show in the list that there are new suggestions" do
- within_object("#your-proposals", @my_proposal) do
- assert page.has_content?("2 new suggestions"), "proposal should indicate it has new suggestions"
- end
+ should "see a link to submit a new proposal" do
+ assert page.has_content?('Propose another talk')
end
- context "but I've updated my proposal since" do
- setup do
- Timecop.travel 5.minutes.from_now
- @my_proposal.description = "Blah blah blah"
- @my_proposal.save!
- visit "/dashboard"
- end
+ should "see a call to action to submit a new proposal" do
+ assert page.has_content?('to submit or edit a proposal')
+ end
- should "show in the list that there are no new suggestions" do
- within_object("#your-proposals", @my_proposal) do
- assert !page.has_content?('new suggestions'), "proposal should not appear to have new suggestions"
- end
- end
+ should "see a call to action to vote for proposals" do
+ assert page.has_content?('to cast your votes for proposals!')
+ end
- should "not show my proposal as changed" do
- assert !page.has_css?("#things-have-changed"), "my proposal shouldn't be in the changed list"
+ should "see a list of proposals I made" do
+ within('#your-proposals') do
+ assert page.has_content?(@my_proposal.title), "proposal was missing"
end
end
- context "but I've added a suggestion to my proposal since" do
+ context "and some new suggestions have been made for one of my proposals" do
setup do
Timecop.travel 5.minutes.from_now
+ FactoryGirl.create(:suggestion, :proposal => @my_proposal)
FactoryGirl.create(:suggestion, :proposal => @my_proposal, :author => @me)
+ Timecop.travel 5.minutes.from_now
+ FactoryGirl.create(:suggestion, :proposal => @my_proposal)
+ FactoryGirl.create(:suggestion, :proposal => @my_proposal)
visit "/dashboard"
end
- should "show in the list that there are no new suggestions" do
+ should "show in the list that there are new suggestions" do
within_object("#your-proposals", @my_proposal) do
- assert !page.has_content?('new suggestions'), "proposal should not appear to have new suggestions"
+ assert page.has_content?("2 new suggestions"), "proposal should indicate it has new suggestions"
end
end
- end
- end
- should "see a list of talks that I haven't made any suggestions for" do
- within('#you-should-look-at-these') do
- assert page.has_content?(@proposal1.title), "proposal1 was missing"
- assert page.has_content?(@proposal2.title), "proposal2 was missing"
- assert page.has_content?(@proposal3.title), "proposal3 was missing"
- end
- end
+ context "but I've updated my proposal since" do
+ setup do
+ Timecop.travel 5.minutes.from_now
+ @my_proposal.description = "Blah blah blah"
+ @my_proposal.save!
+ visit "/dashboard"
+ end
+
+ should "show in the list that there are no new suggestions" do
+ within_object("#your-proposals", @my_proposal) do
+ assert !page.has_content?('new suggestions'), "proposal should not appear to have new suggestions"
+ end
+ end
- should 'not be prompted to look at a withdrawn proposal I haven\'t been involved with' do
- within('#you-should-look-at-these') do
- assert page.has_no_content?(@withdrawn_proposal.title), 'withdrawn_proposal is present, should be missing'
+ should "not show my proposal as changed" do
+ assert !page.has_css?("#things-have-changed"), "my proposal shouldn't be in the changed list"
+ end
+ end
+
+ context "but I've added a suggestion to my proposal since" do
+ setup do
+ Timecop.travel 5.minutes.from_now
+ FactoryGirl.create(:suggestion, :proposal => @my_proposal, :author => @me)
+ visit "/dashboard"
+ end
+
+ should "show in the list that there are no new suggestions" do
+ within_object("#your-proposals", @my_proposal) do
+ assert !page.has_content?('new suggestions'), "proposal should not appear to have new suggestions"
+ end
+ end
+ end
end
- end
- should "link to individual suggestions" do
- click_link @proposal1.title
- assert_equal proposal_path(@proposal1), current_path
- end
+ should "see a list of talks that I haven't made any suggestions for" do
+ within('#you-should-look-at-these') do
+ assert page.has_content?(@proposal1.title), "proposal1 was missing"
+ assert page.has_content?(@proposal2.title), "proposal2 was missing"
+ assert page.has_content?(@proposal3.title), "proposal3 was missing"
+ end
+ end
- should "not see proposals I made in the list of talks requiring suggestions" do
- within('#you-should-look-at-these') do
- assert !page.has_content?(@my_proposal.title), "my proposal shouldn't be presented as requiring suggestions"
+ should 'not be prompted to look at a withdrawn proposal I haven\'t been involved with' do
+ within('#you-should-look-at-these') do
+ assert page.has_no_content?(@withdrawn_proposal.title), 'withdrawn_proposal is present, should be missing'
+ end
end
- end
- context "And I have made suggestions for one of the talks" do
- setup do
- FactoryGirl.create(:suggestion, :proposal => @proposal1, :author => @me)
- visit '/dashboard'
+ should "link to individual suggestions" do
+ click_link @proposal1.title
+ assert_equal proposal_path(@proposal1), current_path
end
- should "not see that talk in the list I haven't made suggestions for" do
+ should "not see proposals I made in the list of talks requiring suggestions" do
within('#you-should-look-at-these') do
- assert !page.has_content?(@proposal1.title), "proposal1 shouldn't be in the attention list"
+ assert !page.has_content?(@my_proposal.title), "my proposal shouldn't be presented as requiring suggestions"
end
end
- context "and I have made suggestions for other talks with recent activity" do
+ context "And I have made suggestions for one of the talks" do
setup do
- FactoryGirl.create(:suggestion, :author => @me, :proposal => @proposal2)
- Timecop.travel 10.minutes
- @proposal2.update_attributes! :description => 'Now more interesting than before.'
+ FactoryGirl.create(:suggestion, :proposal => @proposal1, :author => @me)
visit '/dashboard'
end
- should "not see that talk in my list of proposals with recent activity" do
- within('#things-have-changed') do
- assert !page.has_content?(@proposal1.title), "proposal1 shouldn't be in the changed list"
+ should "not see that talk in the list I haven't made suggestions for" do
+ within('#you-should-look-at-these') do
+ assert !page.has_content?(@proposal1.title), "proposal1 shouldn't be in the attention list"
end
end
- end
- context "And the talk is then updated by the proposer" do
- setup do
- Timecop.travel 10.minutes.from_now
-
- @proposal1.description = "I will, of course, be covering what you need to look out for when using this gem on JRuby."
- @proposal1.save!
+ context "and I have made suggestions for other talks with recent activity" do
+ setup do
+ FactoryGirl.create(:suggestion, :author => @me, :proposal => @proposal2)
+ Timecop.travel 10.minutes
+ @proposal2.update_attributes! :description => 'Now more interesting than before.'
+ visit '/dashboard'
+ end
- Timecop.travel 1.minute.from_now
- visit '/dashboard'
+ should "not see that talk in my list of proposals with recent activity" do
+ within('#things-have-changed') do
+ assert !page.has_content?(@proposal1.title), "proposal1 shouldn't be in the changed list"
+ end
+ end
end
- should "see that talk in my list of proposals with recent activity" do
- within('#things-have-changed') do
- assert page.has_content?(@proposal1.title), "proposal1 should be in the changed list"
+ context "And the talk is then updated by the proposer" do
+ setup do
+ Timecop.travel 10.minutes.from_now
+
+ @proposal1.description = "I will, of course, be covering what you need to look out for when using this gem on JRuby."
+ @proposal1.save!
+
+ Timecop.travel 1.minute.from_now
+ visit '/dashboard'
+ end
+
+ should "see that talk in my list of proposals with recent activity" do
+ within('#things-have-changed') do
+ assert page.has_content?(@proposal1.title), "proposal1 should be in the changed list"
+ end
end
end
- end
- context 'And the talk is then withdrawn by the proposer' do
- setup do
- Timecop.travel 10.minutes.from_now
- FactoryGirl.create(:suggestion, :author => @me, :proposal => @proposal2)
- @proposal1.withdraw!
+ context 'And the talk is then withdrawn by the proposer' do
+ setup do
+ Timecop.travel 10.minutes.from_now
+ FactoryGirl.create(:suggestion, :author => @me, :proposal => @proposal2)
+ @proposal1.withdraw!
- Timecop.travel 10.minutes
- @proposal2.update_attributes! :description => 'Now more interesting than before.'
+ Timecop.travel 10.minutes
+ @proposal2.update_attributes! :description => 'Now more interesting than before.'
- Timecop.travel 1.minute.from_now
- visit '/dashboard'
- end
+ Timecop.travel 1.minute.from_now
+ visit '/dashboard'
+ end
- should 'not see that talk in my list of propopsals with recent activity' do
- within('#things-have-changed') do
- assert page.has_no_content?(@proposal1.title), "proposal1 should not be in the changed list"
+ should 'not see that talk in my list of propopsals with recent activity' do
+ within('#things-have-changed') do
+ assert page.has_no_content?(@proposal1.title), "proposal1 should not be in the changed list"
+ end
end
- end
- should 'see that talk in my list of withdrawn propopsals' do
- within('#things-have-ended') do
- assert page.has_content?(@proposal1.title), "proposal1 should be in the withdrawn list"
+ should 'see that talk in my list of withdrawn propopsals' do
+ within('#things-have-ended') do
+ assert page.has_content?(@proposal1.title), "proposal1 should be in the withdrawn list"
+ end
end
end
end
end
+ end
+ end
+ context "During interlude" do
+ setup do
+ Phase.stubs(:current).returns(Phase::INTERLUDE)
end
+ context "given a bunch of proposals with varying amounts of feedback" do
+ setup do
+ @me = FactoryGirl.create(:user)
+
+ @proposal1 = FactoryGirl.create(:proposal)
+ @proposal2 = FactoryGirl.create(:proposal)
+ @proposal3 = FactoryGirl.create(:proposal)
+
+ @withdrawn_proposal = FactoryGirl.create(:proposal, withdrawn: true)
+
+ @my_proposal = FactoryGirl.create(:proposal, :proposer => @me)
+
+ FactoryGirl.create(:suggestion, :proposal => @proposal2)
+ FactoryGirl.create(:suggestion, :proposal => @proposal2)
+ FactoryGirl.create(:suggestion, :proposal => @proposal2)
+
+ FactoryGirl.create(:suggestion, :proposal => @proposal1)
+ end
+
+ context "When I visit my dashboard" do
+ setup do
+ sign_in @me
+ visit "/dashboard"
+ end
+
+ should "not see a link to submit a new proposal" do
+ refute page.has_content?('Propose another talk')
+ end
+
+ should "not see a call to action to submit a new proposal" do
+ refute page.has_content?('to submit or edit a proposal')
+ end
+
+ should "see a call to action to vote for proposals" do
+ assert page.has_content?('to cast your votes for proposals!')
+ end
+
+ should "see a list of proposals I made" do
+ within('#your-proposals') do
+ assert page.has_content?(@my_proposal.title), "proposal was missing"
+ end
+ end
+
+ should "link to individual suggestions" do
+ click_link @proposal1.title
+ assert_equal proposal_path(@proposal1), current_path
+ end
+ end
+ end
end
end
\ No newline at end of file
diff --git a/test/integration/proposal_suggestion_test.rb b/test/integration/proposal_suggestion_test.rb
index 6cd0dc8..a02fec5 100644
--- a/test/integration/proposal_suggestion_test.rb
+++ b/test/integration/proposal_suggestion_test.rb
@@ -1,71 +1,76 @@
require "test_helper"
class ProposalSuggestionTest < IntegrationTestCase
-
- context "Given a talk proposal" do
- setup do
- @proposer = FactoryGirl.create(:user)
- @proposal = FactoryGirl.create(:proposal, :proposer => @proposer)
- end
-
- context "a visitor viewing the proposal" do
+ [Phase::ONE].each do |phase|
+ context "During '#{phase.name}'" do
setup do
- visit proposal_path(@proposal)
+ Phase.stubs(:current).returns(phase)
end
- should "not be able to suggest anything" do
- refute page.has_css?("form[action='#{proposal_suggestions_path(@proposal)}']")
- end
-
- context 'when there are some suggestions already' do
+ context "Given a talk proposal" do
setup do
- @other_suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :created_at => 2.days.ago, :updated_at => 2.days.ago)
+ @proposer = FactoryGirl.create(:user)
+ @proposal = FactoryGirl.create(:proposal, :proposer => @proposer)
end
- should "be able to subscribe to the rss feed of suggestions to the proposal" do
- assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposal_path(@proposal, :format => :rss)}']")
- visit proposal_path(@proposal, :format => :rss)
- assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
+ context "a visitor viewing the proposal" do
+ setup do
+ visit proposal_path(@proposal)
+ end
+
+ should "not be able to suggest anything" do
+ refute page.has_css?("form[action='#{proposal_suggestions_path(@proposal)}']")
+ end
+
+ context 'when there are some suggestions already' do
+ setup do
+ @other_suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :created_at => 2.days.ago, :updated_at => 2.days.ago)
+ end
+
+ should "be able to subscribe to the rss feed of suggestions to the proposal" do
+ assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposal_path(@proposal, :format => :rss)}']")
+ visit proposal_path(@proposal, :format => :rss)
+ assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
+ end
+
+ should 'see the existing suggestions in the feed' do
+ visit proposal_path(@proposal, :format => :rss)
+ assert page.has_xpath?('.//item/title', :text => "Suggestion from #{@other_suggestion.author.name} (@#{@other_suggestion.author.github_nickname})")
+ assert page.has_xpath?('.//item/description', :text => @other_suggestion.body)
+ end
+
+ should "not be able to edit an existing suggestion of someone else" do
+ refute page.has_css?("form[action='#{proposal_suggestion_path(@proposal, @other_suggestion)}']")
+ end
+ end
end
- should 'see the existing suggestions in the feed' do
- visit proposal_path(@proposal, :format => :rss)
- assert page.has_xpath?('.//item/title', :text => "Suggestion from #{@other_suggestion.author.name} (@#{@other_suggestion.author.github_nickname})")
- assert page.has_xpath?('.//item/description', :text => @other_suggestion.body)
- end
+ context "a logged in user viewing the proposal" do
+ setup do
+ @me = FactoryGirl.create(:user)
+ sign_in @me
+ visit proposal_path(@proposal)
+ end
- should "not be able to edit an existing suggestion of someone else" do
- refute page.has_css?("form[action='#{proposal_suggestion_path(@proposal, @other_suggestion)}']")
- end
- end
- end
+ should "be able to subscribe to the rss feed of suggestions to the proposal" do
+ assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposal_path(@proposal, :format => :rss)}']")
+ visit proposal_path(@proposal, :format => :rss)
+ assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
+ end
- context "a logged in user viewing the proposal" do
- setup do
- @me = FactoryGirl.create(:user)
- sign_in @me
- visit proposal_path(@proposal)
- end
+ should "see a call to action asking for help to develop the proposal" do
+ assert page.has_content?("Help develop this into a good proposal")
+ end
- should "be able to subscribe to the rss feed of suggestions to the proposal" do
- assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposal_path(@proposal, :format => :rss)}']")
- visit proposal_path(@proposal, :format => :rss)
- assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
- end
+ should "be able to make a suggestion about the proposal" do
+ suggest "I think you should focus on the first bit, because that's going to be more interesting to newbies."
- should "see a call to action asking for help to develop the proposal" do
- assert page.has_content?("Help develop this into a good proposal")
- end
+ assert_page_has_suggestion :body => "I think you should focus on the first bit, because that's going to be more interesting to newbies.",
+ :author => @me
+ end
- should "be able to make a suggestion about the proposal" do
- suggest "I think you should focus on the first bit, because that's going to be more interesting to newbies."
-
- assert_page_has_suggestion :body => "I think you should focus on the first bit, because that's going to be more interesting to newbies.",
- :author => @me
- end
-
- should "be able to make a suggestion about the proposal and preserve the markdown content when displaying it" do
- suggest %{
+ should "be able to make a suggestion about the proposal and preserve the markdown content when displaying it" do
+ suggest %{
1. change the title - it's not really clear
2. put more emphasis on how you'd test your approach
3. cover this gem: http://rubygems.org/gems/sausage-mcmuffin
@@ -73,130 +78,222 @@ class ProposalSuggestionTest < IntegrationTestCase
Other than that, sounds great!
}
- within ".suggestions" do
- assert page.has_css?("ol li", :text => "change the title - it's not really clear")
- assert page.has_css?("ol li", :text => "put more emphasis on how you'd test your approach")
- assert page.has_css?("ol li", :text => "cover this gem: http://rubygems.org/gems/sausage-mcmuffin")
- assert page.has_css?("ol li a[href='http://rubygems.org/gems/sausage-mcmuffin']", :text => 'http://rubygems.org/gems/sausage-mcmuffin')
- assert page.has_css?("p", :text => "Other than that, sounds great!")
+ within ".suggestions" do
+ assert page.has_css?("ol li", :text => "change the title - it's not really clear")
+ assert page.has_css?("ol li", :text => "put more emphasis on how you'd test your approach")
+ assert page.has_css?("ol li", :text => "cover this gem: http://rubygems.org/gems/sausage-mcmuffin")
+ assert page.has_css?("ol li a[href='http://rubygems.org/gems/sausage-mcmuffin']", :text => 'http://rubygems.org/gems/sausage-mcmuffin')
+ assert page.has_css?("p", :text => "Other than that, sounds great!")
+ end
+ end
+
+ context 'when there are some suggestions already' do
+ setup do
+ @other_suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :created_at => 2.days.ago, :updated_at => 2.days.ago)
+ end
+
+ should "be able to subscribe to the rss feed of suggestions to the proposal" do
+ assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposal_path(@proposal, :format => :rss)}']")
+ visit proposal_path(@proposal, :format => :rss)
+ assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
+ end
+
+ should 'see the existing suggestions in the feed' do
+ visit proposal_path(@proposal, :format => :rss)
+ assert page.has_xpath?('.//item/title', :text => "Suggestion from #{@other_suggestion.author.name} (@#{@other_suggestion.author.github_nickname})")
+ assert page.has_xpath?('.//item/description', :text => @other_suggestion.body)
+ end
+
+ should 'be able to add a new suggestion and see it in the feed at the top' do
+ suggest "I think you should focus on the first bit, because that's going to be more interesting to newbies."
+
+ visit proposal_path(@proposal, :format => :rss)
+
+ assert page.has_xpath?('.//item[position() = 2]/title', :text => "Suggestion from #{@other_suggestion.author.name} (@#{@other_suggestion.author.github_nickname})")
+ assert page.has_xpath?('.//item[position() = 2]/description', :text => @other_suggestion.body)
+
+ assert page.has_xpath?('.//item[position() = 1]/title', :text => "Suggestion from #{@me.name} (@#{@me.github_nickname})")
+ assert page.has_xpath?('.//item[position() = 1]/description', :text => "I think you should focus on the first bit, because that's going to be more interesting to newbies.")
+ end
+
+ should "not be able to edit an existing suggestion of someone else" do
+ refute page.has_css?("form[action='#{proposal_suggestion_path(@proposal, @other_suggestion)}']")
+ end
+
+ should "not be able to edit an existing suggestion of their own" do
+ own_suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :author => @me)
+ visit proposal_path(@proposal)
+
+ refute page.has_css?("form[action='#{proposal_suggestion_path(@proposal, own_suggestion)}']")
+ end
+ end
+
+ should "anonymise suggestions by the proposer" do
+ suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :author => @proposer)
+ visit proposal_path(@proposal)
+
+ assert page.has_no_content?(@proposer.name)
+ assert page.has_content?("The proposal author")
+ end
+
+ should "not be able to make an empty suggestion" do
+ suggest ""
+ i_am_warned_about Suggestion, :body, "can't be blank"
+ end
+
+ should "be required to provide a substantial suggestion" do
+ suggest "x"*49
+ i_am_warned_about Suggestion, :body, "should be a meaningful contribution or criticism (i.e. at least 50 characters)"
+ end
+
+ should "not be able to make a '+1' suggestion" do
+ suggest "+1"
+ i_am_warned_about Suggestion, :body, "should contain some concrete suggestions about how to develop this proposal"
+ end
+
+ should "not be able to make a '-1' suggestion" do
+ suggest "-1"
+ i_am_warned_about Suggestion, :body, "should contain some concrete suggestions about how to develop this proposal"
+ end
end
- end
- context 'when there are some suggestions already' do
- setup do
- @other_suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :created_at => 2.days.ago, :updated_at => 2.days.ago)
- end
+ context "a proposer viewing their proposal" do
+ setup do
+ sign_in @proposer
+ visit proposal_path(@proposal)
+ end
- should "be able to subscribe to the rss feed of suggestions to the proposal" do
- assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposal_path(@proposal, :format => :rss)}']")
- visit proposal_path(@proposal, :format => :rss)
- assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
- end
+ should "see a call to action explaining anonymisation" do
+ assert page.has_content?("your identity will be masked from other visitors")
+ end
- should 'see the existing suggestions in the feed' do
- visit proposal_path(@proposal, :format => :rss)
- assert page.has_xpath?('.//item/title', :text => "Suggestion from #{@other_suggestion.author.name} (@#{@other_suggestion.author.github_nickname})")
- assert page.has_xpath?('.//item/description', :text => @other_suggestion.body)
- end
+ should "see their suggestions identified as their own" do
+ suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :author => @proposer)
+ visit proposal_path(@proposal)
- should 'be able to add a new suggestion and see it in the feed at the top' do
- suggest "I think you should focus on the first bit, because that's going to be more interesting to newbies."
+ assert page.has_content?("You respond")
+ end
- visit proposal_path(@proposal, :format => :rss)
+ should "not be able to edit an existing suggestion of their own" do
+ own_suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :author => @proposer)
+ visit proposal_path(@proposal)
- assert page.has_xpath?('.//item[position() = 2]/title', :text => "Suggestion from #{@other_suggestion.author.name} (@#{@other_suggestion.author.github_nickname})")
- assert page.has_xpath?('.//item[position() = 2]/description', :text => @other_suggestion.body)
+ refute page.has_css?("form[action='#{proposal_suggestion_path(@proposal, own_suggestion)}']")
+ end
- assert page.has_xpath?('.//item[position() = 1]/title', :text => "Suggestion from #{@me.name} (@#{@me.github_nickname})")
- assert page.has_xpath?('.//item[position() = 1]/description', :text => "I think you should focus on the first bit, because that's going to be more interesting to newbies.")
- end
+ should "not be able to edit an existing suggestion of someone else" do
+ other_suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal)
+ visit proposal_path(@proposal)
- should "not be able to edit an existing suggestion of someone else" do
- refute page.has_css?("form[action='#{proposal_suggestion_path(@proposal, @other_suggestion)}']")
+ refute page.has_css?("form[action='#{proposal_suggestion_path(@proposal, other_suggestion)}']")
+ end
end
- should "not be able to edit an existing suggestion of their own" do
- own_suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :author => @me)
- visit proposal_path(@proposal)
+ context "a moderator viewing a proposal with suggestions" do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :created_at => 2.days.ago, :updated_at => 2.days.ago)
+ sign_in FactoryGirl.create(:user, :email => 'moderator@euruko2013.org')
+ visit proposal_path(@proposal)
+ end
- refute page.has_css?("form[action='#{proposal_suggestion_path(@proposal, own_suggestion)}']")
+ should "be able to edit the suggestion" do
+ assert page.has_css?("form[action='#{proposal_suggestion_path(@proposal, @suggestion)}']")
+ end
end
end
+ end
+ end
- should "anonymise suggestions by the proposer" do
- suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :author => @proposer)
- visit proposal_path(@proposal)
-
- assert page.has_no_content?(@proposer.name)
- assert page.has_content?("The proposal author")
+ [Phase.all - [Phase::ONE]].flatten.each do |phase|
+ context "During '#{phase.name}'" do
+ setup do
+ Phase.stubs(:current).returns(phase)
end
- should "not be able to make an empty suggestion" do
- suggest ""
- i_am_warned_about Suggestion, :body, "can't be blank"
- end
+ context "Given a talk proposal" do
+ setup do
+ @proposer = FactoryGirl.create(:user)
+ @proposal = FactoryGirl.create(:proposal, :proposer => @proposer)
+ end
- should "be required to provide a substantial suggestion" do
- suggest "x"*49
- i_am_warned_about Suggestion, :body, "should be a meaningful contribution or criticism (i.e. at least 50 characters)"
- end
+ context "a visitor viewing the proposal" do
+ setup do
+ visit proposal_path(@proposal)
+ end
- should "not be able to make a '+1' suggestion" do
- suggest "+1"
- i_am_warned_about Suggestion, :body, "should contain some concrete suggestions about how to develop this proposal"
- end
+ should "not be able to suggest anything" do
+ refute page.has_css?("form[action='#{proposal_suggestions_path(@proposal)}']")
+ end
+ end
- should "not be able to make a '-1' suggestion" do
- suggest "-1"
- i_am_warned_about Suggestion, :body, "should contain some concrete suggestions about how to develop this proposal"
- end
- end
+ context "a logged in user viewing the proposal" do
+ setup do
+ @me = FactoryGirl.create(:user)
+ sign_in @me
+ visit proposal_path(@proposal)
+ end
- context "a proposer viewing their proposal" do
- setup do
- sign_in @proposer
- visit proposal_path(@proposal)
- end
+ should "not be able to suggest anything" do
+ refute page.has_css?("form[action='#{proposal_suggestions_path(@proposal)}']")
+ end
- should "see a call to action explaining anonymisation" do
- assert page.has_content?("your identity will be masked from other visitors")
- end
+ should "anonymise suggestions by the proposer" do
+ suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :author => @proposer)
+ visit proposal_path(@proposal)
- should "see their suggestions identified as their own" do
- suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :author => @proposer)
- visit proposal_path(@proposal)
+ assert page.has_no_content?(@proposer.name)
+ assert page.has_content?("The proposal author")
+ end
+ end
- assert page.has_content?("You respond")
- end
+ context "a proposer viewing their proposal" do
+ setup do
+ sign_in @proposer
+ visit proposal_path(@proposal)
+ end
- should "not be able to edit an existing suggestion of their own" do
- own_suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :author => @proposer)
- visit proposal_path(@proposal)
+ should "see their suggestions identified as their own" do
+ suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :author => @proposer)
+ visit proposal_path(@proposal)
- refute page.has_css?("form[action='#{proposal_suggestion_path(@proposal, own_suggestion)}']")
- end
+ assert page.has_content?("You respond")
+ end
- should "not be able to edit an existing suggestion of someone else" do
- other_suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal)
- visit proposal_path(@proposal)
+ should "not be able to edit an existing suggestion of their own" do
+ own_suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :author => @proposer)
+ visit proposal_path(@proposal)
- refute page.has_css?("form[action='#{proposal_suggestion_path(@proposal, other_suggestion)}']")
- end
- end
+ refute page.has_css?("form[action='#{proposal_suggestion_path(@proposal, own_suggestion)}']")
+ end
- context "a moderator viewing a proposal with suggestions" do
- setup do
- @suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :created_at => 2.days.ago, :updated_at => 2.days.ago)
- sign_in FactoryGirl.create(:user, :email => 'moderator@euruko2013.org')
- visit proposal_path(@proposal)
- end
+ should "not be able to edit an existing suggestion of someone else" do
+ other_suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal)
+ visit proposal_path(@proposal)
- should "be able to edit the suggestion" do
- assert page.has_css?("form[action='#{proposal_suggestion_path(@proposal, @suggestion)}']")
+ refute page.has_css?("form[action='#{proposal_suggestion_path(@proposal, other_suggestion)}']")
+ end
+ end
+
+ context "a moderator viewing a proposal with suggestions" do
+ setup do
+ @suggestion = FactoryGirl.create(:suggestion, :proposal => @proposal, :created_at => 2.days.ago, :updated_at => 2.days.ago)
+ sign_in FactoryGirl.create(:user, :email => 'moderator@euruko2013.org')
+ visit proposal_path(@proposal)
+ end
+
+ should "be able to edit the suggestion" do
+ assert page.has_css?("form[action='#{proposal_suggestion_path(@proposal, @suggestion)}']")
+ end
+ end
end
end
end
+
+ #########
+ protected
+ #########
+
def suggest(body)
fill_in "suggestion[body]", :with => body
click_button "Make your suggestion"
diff --git a/test/integration/proposal_test.rb b/test/integration/proposal_test.rb
index 3b3a077..6e22f02 100644
--- a/test/integration/proposal_test.rb
+++ b/test/integration/proposal_test.rb
@@ -1,215 +1,478 @@
-
require "test_helper"
class ProposalTest < IntegrationTestCase
-
- context "As a visitor to the site" do
- should "not see a link to propose a talk" do
- visit proposals_path
- assert !page.has_content?("Propose talk"), "link to propose talk should not be present!"
- end
-
- should "not be able to propose a talk" do
- visit new_proposal_path
- i_am_asked_to_sign_in
- end
-
- context "given a proposal already exists" do
+ [Phase::ONE].each do |phase|
+ context "During '#{phase.name}'" do
setup do
- @proposal = FactoryGirl.create(:proposal, :title => "Ruby Muby Schmuby")
+ Phase.stubs(:current).returns(phase)
end
- should "be able to see the list of proposals" do
- visit proposals_path
- assert page.has_css?('ul.proposals')
- end
+ context "As a visitor to the site" do
+ should "not see a link to propose a talk" do
+ visit proposals_path
+ assert !page.has_content?("Propose a talk"), "link to propose talk should not be present!"
+ end
- should "be able to subscribe to the rss feed of proposals" do
- visit proposals_path
- assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposals_path(:format => :rss)}']")
- visit proposals_path(:format => :rss)
- assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
- assert page.has_xpath?('.//item/title', :text => @proposal.title)
- end
+ should "not see a link to vote for a talk" do
+ visit proposals_path
+ assert !page.has_content?("Cast your votes!"), "link to vote talks should not be present!"
+ end
- should "be able to read individual proposals" do
- visit proposals_path
- click_link "Ruby Muby Schmuby"
- assert_page_has_proposal :title => "Ruby Muby Schmuby"
- end
+ should "not be able to propose a talk" do
+ visit new_proposal_path
+ i_am_asked_to_sign_in
+ end
- should "not see a link to edit a proposal" do
- visit proposals_path
- click_link "Ruby Muby Schmuby"
- assert !page.has_content?("Edit proposal"), "link to edit proposal should not be present"
- end
+ context "given a proposal already exists" do
+ setup do
+ @proposal = FactoryGirl.create(:proposal, :title => "Ruby Muby Schmuby")
+ end
- should "not be able to edit a proposal" do
- visit edit_proposal_path(@proposal)
- i_am_asked_to_sign_in
- end
+ should "be able to see the list of proposals" do
+ visit proposals_path
+ assert page.has_css?('ul.proposals')
+ end
- should "my page view be tracked" do
- assert_difference(lambda { @proposal.impressionist_count }, 1) do
- visit proposal_path(@proposal)
- end
- end
- end
- end
+ should "be able to subscribe to the rss feed of proposals" do
+ visit proposals_path
+ assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposals_path(:format => :rss)}']")
+ visit proposals_path(:format => :rss)
+ assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
+ assert page.has_xpath?('.//item/title', :text => @proposal.title)
+ end
- context "Given I am logged in" do
- setup do
- @user = FactoryGirl.create(:user)
- sign_in @user
- end
+ should "be able to read individual proposals" do
+ visit proposals_path
+ click_link "Ruby Muby Schmuby"
+ assert_page_has_proposal :title => "Ruby Muby Schmuby"
+ end
- context "and I propose a talk with all the required details" do
- setup { propose_talk :title => "My Amazing Talk", :description => 'This talk is amazing.' }
-
- should "be able to see my proposal on the site" do
- visit proposals_path
- click_link "My Amazing Talk"
- assert_page_has_proposal \
- :title => "My Amazing Talk",
- :description => 'This talk is amazing.',
- :proposer => @user
- assert !page.has_css?('script', text: 'pwned')
- end
+ should "not see a link to edit a proposal" do
+ visit proposals_path
+ click_link "Ruby Muby Schmuby"
+ assert !page.has_content?("Edit proposal"), "link to edit proposal should not be present"
+ end
- should "be able to withdraw my proposal" do
- visit proposals_path
- click_link "My Amazing Talk"
- click_link "Withdraw proposal"
+ should "not be able to edit a proposal" do
+ visit edit_proposal_path(@proposal)
+ i_am_asked_to_sign_in
+ end
- assert_proposal_withdrawn "My Amazing Talk"
+ should "my page view be tracked" do
+ assert_difference(lambda { @proposal.impressionist_count }, 1) do
+ visit proposal_path(@proposal)
+ end
+ end
+ end
end
- context "and I withdraw my proposal" do
+ context "Given I am logged in" do
setup do
- visit proposals_path
- click_link "My Amazing Talk"
- click_link "Withdraw proposal"
+ @user = FactoryGirl.create(:user)
+ sign_in @user
end
- should "be able to re-publish my withdrawn proposal" do
+ should "see a link to propose a talk" do
visit proposals_path
- click_link "My Amazing Talk"
- click_link "Re-publish proposal"
- assert_proposal_republished
+ assert page.has_content?("Propose a talk"), "link to propose talk should be present!"
end
- end
- context "and then edit my proposal" do
- setup do
+
+ should "not see a link to vote for a talk" do
visit proposals_path
- click_link "My Amazing Talk"
- click_link "Edit proposal"
+ assert !page.has_content?("Cast your votes!"), "link to vote talks should not be present!"
end
- context "with valid content" do
- setup do
- fill_in "Title", :with => "My Even More Amazing Talk"
- fill_in "Description", :with => "This talk is wildly amazing."
- click_button "Update proposal"
- end
+ context "and I propose a talk with all the required details" do
+ setup { propose_talk :title => "My Amazing Talk", :description => 'This talk is amazing.' }
- should "update the proposal" do
+ should "be able to see my proposal on the site" do
visit proposals_path
- click_link "My Even More Amazing Talk"
+ click_link "My Amazing Talk"
assert_page_has_proposal \
- :title => "My Even More Amazing Talk",
- :description => 'This talk is wildly amazing.',
- :proposer => @user
+ :title => "My Amazing Talk",
+ :description => 'This talk is amazing.',
+ :proposer => @user
+ assert !page.has_css?('script', text: 'pwned')
+ end
+
+ should "be able to withdraw my proposal" do
+ visit proposals_path
+ click_link "My Amazing Talk"
+ click_link "Withdraw proposal"
+
+ assert_proposal_withdrawn "My Amazing Talk"
+ end
+
+ context "and I withdraw my proposal" do
+ setup do
+ visit proposals_path
+ click_link "My Amazing Talk"
+ click_link "Withdraw proposal"
+ end
+
+ should "be able to re-publish my withdrawn proposal" do
+ visit proposals_path
+ click_link "My Amazing Talk"
+ click_link "Re-publish proposal"
+ assert_proposal_republished
+ end
+ end
+ context "and then edit my proposal" do
+ setup do
+ visit proposals_path
+ click_link "My Amazing Talk"
+ click_link "Edit proposal"
+ end
+
+ context "with valid content" do
+ setup do
+ fill_in "Title", :with => "My Even More Amazing Talk"
+ fill_in "Description", :with => "This talk is wildly amazing."
+ click_button "Update proposal"
+ end
+
+ should "update the proposal" do
+ visit proposals_path
+ click_link "My Even More Amazing Talk"
+ assert_page_has_proposal \
+ :title => "My Even More Amazing Talk",
+ :description => 'This talk is wildly amazing.',
+ :proposer => @user
+ end
+ end
+
+ context "and remove the title" do
+ setup do
+ fill_in "Title", :with => ""
+ click_button "Update proposal"
+ end
+
+ should "alert me that the title is required" do
+ i_am_warned_about Proposal, :title, "can't be blank"
+ end
+ end
end
end
- context "and remove the title" do
+ context "and I propose a talk with markdown-formatted description" do
setup do
- fill_in "Title", :with => ""
- click_button "Update proposal"
+ propose_talk :title => "My Amazing Talk", :description => %{
+# A moment in time
+
+blah blah blah
+ }.strip
+ end
+
+ should "be able to see my proposal with a formatted description" do
+ visit proposals_path
+ click_link "My Amazing Talk"
+ within_proposal do
+ within(".description") do
+ assert page.has_css?('h1', :text => 'A moment in time')
+ assert page.has_css?('p', :text => 'blah blah blah')
+ end
+ end
end
+ end
+
+ context "and I propose a talk without a title" do
+ setup { propose_talk :title => nil }
should "alert me that the title is required" do
i_am_warned_about Proposal, :title, "can't be blank"
end
end
- end
- end
- context "and I propose a talk with markdown-formatted description" do
- setup do
- propose_talk :title => "My Amazing Talk", :description => %{
+ context "and a proposal from another user exists" do
+ setup do
+ @other_persons_proposal = FactoryGirl.create(:proposal, :title => "Another talk")
+ end
+
+ should "not see a link to edit that proposal" do
+ visit proposals_path
+ click_link "Another talk"
+ assert !page.has_content?("Edit proposal"), "link to edit proposal should not be present"
+ end
+
+ should "not be able to edit that proposal" do
+ visit edit_proposal_path(@other_persons_proposal)
+ i_am_not_authorized
+ end
+ end
+
+ context "and there are some proposals (mine and others)" do
+ setup do
+ propose_talk :title => "My Amazing Talk", :description => %{
# A moment in time
blah blah blah
}.strip
- end
+ @other_persons_proposal = FactoryGirl.create(:proposal, :title => "Another talk", :created_at => 3.days.ago)
+ end
- should "be able to see my proposal with a formatted description" do
- visit proposals_path
- click_link "My Amazing Talk"
- within_proposal do
- within(".description") do
- assert page.has_css?('h1', :text => 'A moment in time')
- assert page.has_css?('p', :text => 'blah blah blah')
+ should "be able to subscribe to the rss feed of proposals" do
+ visit proposals_path
+ assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposals_path(:format => :rss)}']")
+ visit proposals_path(:format => :rss)
+ assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
+ end
+
+ should 'have my talk and the other talk in the feed, in newest first order' do
+ visit proposals_path(:format => :rss)
+ assert page.has_xpath?('.//item[position() = 2]/title', :text => @other_persons_proposal.title)
+ assert page.has_xpath?('.//item[position() = 1]/title', :text => "My Amazing Talk")
end
- end
- end
- end
- context "and I propose a talk without a title" do
- setup { propose_talk :title => nil }
+ should "be able to see other persons proposal and my page view be tracked" do
+ assert_difference(lambda { @other_persons_proposal.impressionist_count }, 1) do
+ visit proposal_path(@other_persons_proposal)
+ end
- should "alert me that the title is required" do
- i_am_warned_about Proposal, :title, "can't be blank"
+ assert_equal 1, @other_persons_proposal.impressionist_count(user_id: @user.id)
+ end
+ end
end
end
+ end
- context "and a proposal from another user exists" do
+ [Phase::INTERLUDE].each do |phase|
+ context "During '#{phase.name}'" do
setup do
- @other_persons_proposal = FactoryGirl.create(:proposal, :title => "Another talk")
+ Phase.stubs(:current).returns(phase)
end
- should "not see a link to edit that proposal" do
- visit proposals_path
- click_link "Another talk"
- assert !page.has_content?("Edit proposal"), "link to edit proposal should not be present"
+ context "As a visitor to the site" do
+ should "not see a link to propose a talk" do
+ visit proposals_path
+ assert !page.has_content?("Propose a talk"), "link to propose talk should not be present!"
+ end
+
+ should "not see a link to vote for a talk" do
+ visit proposals_path
+ assert !page.has_content?("Cast your votes!"), "link to vote talks should not be present!"
+ end
+
+ should "not be able to propose a talk" do
+ visit new_proposal_path
+ i_am_asked_to_sign_in
+ end
+
+ context "given a proposal already exists" do
+ setup do
+ @proposal = FactoryGirl.create(:proposal, :title => "Ruby Muby Schmuby")
+ end
+
+ should "be able to see the list of proposals" do
+ visit proposals_path
+ assert page.has_css?('ul.proposals')
+ end
+
+ should "be able to subscribe to the rss feed of proposals" do
+ visit proposals_path
+ assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposals_path(:format => :rss)}']")
+ visit proposals_path(:format => :rss)
+ assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
+ assert page.has_xpath?('.//item/title', :text => @proposal.title)
+ end
+
+ should "be able to read individual proposals" do
+ visit proposals_path
+ click_link "Ruby Muby Schmuby"
+ assert_page_has_proposal :title => "Ruby Muby Schmuby"
+ end
+
+ should "not see a link to edit a proposal" do
+ visit proposals_path
+ click_link "Ruby Muby Schmuby"
+ assert !page.has_content?("Edit proposal"), "link to edit proposal should not be present"
+ end
+
+ should "not be able to edit a proposal" do
+ visit edit_proposal_path(@proposal)
+ i_am_asked_to_sign_in
+ end
+
+ should "my page view be tracked" do
+ assert_difference(lambda { @proposal.impressionist_count }, 1) do
+ visit proposal_path(@proposal)
+ end
+ end
+ end
end
- should "not be able to edit that proposal" do
- visit edit_proposal_path(@other_persons_proposal)
- i_am_not_authorized
+ context "Given I am logged in" do
+ setup do
+ @user = FactoryGirl.create(:user)
+ sign_in @user
+ end
+
+ should "not see a link to propose a talk" do
+ visit proposals_path
+ assert !page.has_content?("Propose a talk"), "link to propose talk should not be present!"
+ end
+
+ context "given a proposal already exists" do
+ setup do
+ @proposal = FactoryGirl.create(:proposal, :title => "Ruby Muby Schmuby")
+ end
+
+ should "see a link to vote for a talk" do
+ visit proposals_path
+ assert page.has_content?("Cast your votes!"), "link to vote talks should be present!"
+ end
+
+ should "be able to see the list of proposals" do
+ visit proposals_path
+ assert page.has_css?('ul.proposals')
+ end
+
+ should "be able to subscribe to the rss feed of proposals" do
+ visit proposals_path
+ assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposals_path(:format => :rss)}']")
+ visit proposals_path(:format => :rss)
+ assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
+ assert page.has_xpath?('.//item/title', :text => @proposal.title)
+ end
+
+ should "be able to read individual proposals" do
+ visit proposals_path
+ click_link "Ruby Muby Schmuby"
+ assert_page_has_proposal :title => "Ruby Muby Schmuby"
+ end
+
+ should "not see a link to edit a proposal" do
+ visit proposals_path
+ click_link "Ruby Muby Schmuby"
+ assert !page.has_content?("Edit proposal"), "link to edit proposal should not be present"
+ end
+
+ should "not be able to edit a proposal" do
+ visit edit_proposal_path(@proposal)
+ i_am_not_authorized
+ end
+
+ should "my page view be tracked" do
+ assert_difference(lambda { @proposal.impressionist_count }, 1) do
+ visit proposal_path(@proposal)
+ end
+ end
+ end
end
end
+ end
- context "and there are some proposals (mine and others)" do
+ [Phase.all - [Phase::ONE, Phase::INTERLUDE]].flatten.each do |phase|
+ context "During '#{phase.name}'" do
setup do
- propose_talk :title => "My Amazing Talk", :description => %{
-# A moment in time
-
-blah blah blah
- }.strip
- @other_persons_proposal = FactoryGirl.create(:proposal, :title => "Another talk", :created_at => 3.days.ago)
+ Phase.stubs(:current).returns(phase)
end
- should "be able to subscribe to the rss feed of proposals" do
- visit proposals_path
- assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposals_path(:format => :rss)}']")
- visit proposals_path(:format => :rss)
- assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
- end
+ context "As a visitor to the site" do
+ should "not see a link to propose a talk" do
+ visit proposals_path
+ assert !page.has_content?("Propose a talk"), "link to propose talk should not be present!"
+ end
+
+ should "not be able to propose a talk" do
+ visit new_proposal_path
+ i_am_asked_to_sign_in
+ end
+
+ context "given a proposal already exists" do
+ setup do
+ @proposal = FactoryGirl.create(:proposal, :title => "Ruby Muby Schmuby")
+ end
+
+ should "be able to see the list of proposals" do
+ visit proposals_path
+ assert page.has_css?('ul.proposals')
+ end
+
+ should "be able to subscribe to the rss feed of proposals" do
+ visit proposals_path
+ assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposals_path(:format => :rss)}']")
+ visit proposals_path(:format => :rss)
+ assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
+ assert page.has_xpath?('.//item/title', :text => @proposal.title)
+ end
+
+ should "be able to read individual proposals" do
+ visit proposals_path
+ click_link "Ruby Muby Schmuby"
+ assert_page_has_proposal :title => "Ruby Muby Schmuby"
+ end
+
+ should "not see a link to edit a proposal" do
+ visit proposals_path
+ click_link "Ruby Muby Schmuby"
+ assert !page.has_content?("Edit proposal"), "link to edit proposal should not be present"
+ end
+
+ should "not be able to edit a proposal" do
+ visit edit_proposal_path(@proposal)
+ i_am_asked_to_sign_in
+ end
- should 'have my talk and the other talk in the feed, in newest first order' do
- visit proposals_path(:format => :rss)
- assert page.has_xpath?('.//item[position() = 2]/title', :text => @other_persons_proposal.title)
- assert page.has_xpath?('.//item[position() = 1]/title', :text => "My Amazing Talk")
+ should "my page view be tracked" do
+ assert_difference(lambda { @proposal.impressionist_count }, 1) do
+ visit proposal_path(@proposal)
+ end
+ end
+ end
end
- should "be able to see other persons proposal and my page view be tracked" do
- assert_difference(lambda { @other_persons_proposal.impressionist_count }, 1) do
- visit proposal_path(@other_persons_proposal)
+ context "Given I am logged in" do
+ setup do
+ @user = FactoryGirl.create(:user)
+ sign_in @user
+ end
+
+ should "not see a link to propose a talk" do
+ visit proposals_path
+ assert !page.has_content?("Propose a talk"), "link to propose talk should not be present!"
+ end
+
+ should "not be able to propose a talk" do
+ visit new_proposal_path
+ i_am_not_authorized
end
- assert_equal 1, @other_persons_proposal.impressionist_count(user_id: @user.id)
+ context "given a proposal already exists" do
+ setup do
+ @proposal = FactoryGirl.create(:proposal, :title => "Ruby Muby Schmuby")
+ end
+
+ should "be able to see the list of proposals" do
+ visit proposals_path
+ assert page.has_css?('ul.proposals')
+ end
+
+ should "be able to subscribe to the rss feed of proposals" do
+ visit proposals_path
+ assert page.has_css?("link[rel='alternate'][type='application/rss+xml'][href$='#{proposals_path(:format => :rss)}']")
+ visit proposals_path(:format => :rss)
+ assert_match %r{application/rss\+xml}, page.response_headers['Content-Type']
+ assert page.has_xpath?('.//item/title', :text => @proposal.title)
+ end
+
+ should "be able to read individual proposals" do
+ visit proposals_path
+ click_link "Ruby Muby Schmuby"
+ assert_page_has_proposal :title => "Ruby Muby Schmuby"
+ end
+
+ should "not see a link to edit a proposal" do
+ visit proposals_path
+ click_link "Ruby Muby Schmuby"
+ assert !page.has_content?("Edit proposal"), "link to edit proposal should not be present"
+ end
+
+ should "my page view be tracked" do
+ assert_difference(lambda { @proposal.impressionist_count }, 1) do
+ visit proposal_path(@proposal)
+ end
+ end
+ end
end
end
end
diff --git a/test/integration/proposal_voting_test.rb b/test/integration/proposal_voting_test.rb
index 3305155..4ba0afb 100644
--- a/test/integration/proposal_voting_test.rb
+++ b/test/integration/proposal_voting_test.rb
@@ -1,85 +1,159 @@
require "test_helper"
class ProposalVotingTest < IntegrationTestCase
-
- context "Given a talk proposal" do
- setup do
- @proposer = FactoryGirl.create(:user)
- @proposal = FactoryGirl.create(:proposal, :proposer => @proposer)
- end
-
- context "a visitor viewing the proposal" do
+ [Phase::ONE, Phase::INTERLUDE].each do |phase|
+ context "During '#{phase.name}'" do
setup do
- visit proposal_path(@proposal)
+ Phase.stubs(:current).returns(phase)
end
- should "not be able to vote anything" do
- refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :up)}']")
- refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :down)}']")
- end
- end
+ context "Given a talk proposal" do
+ setup do
+ @proposer = FactoryGirl.create(:user)
+ @proposal = FactoryGirl.create(:proposal, :proposer => @proposer)
+ end
- context "a logged in user viewing the proposal" do
- setup do
- @me = FactoryGirl.create(:user)
- sign_in @me
- visit proposal_path(@proposal)
- end
+ context "a visitor viewing the proposal" do
+ setup do
+ visit proposal_path(@proposal)
+ end
- should "see a call to action asking to vote for the proposal" do
- assert page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :up)}']")
- assert page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :down)}']")
- end
+ should "not be able to vote anything" do
+ refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :up)}']")
+ refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :down)}']")
+ end
+ end
+
+ context "a logged in user viewing the proposal" do
+ setup do
+ @me = FactoryGirl.create(:user)
+ sign_in @me
+ visit proposal_path(@proposal)
+ end
+
+ should "see a call to action asking to vote for the proposal" do
+ assert page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :up)}']")
+ assert page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :down)}']")
+ end
+
+ should "be able to vote up a proposal" do
+ vote_up
+ assert_equal 1, @proposal.votes_for
+ i_am_alerted 'Thank you for casting your vote. Your vote has been captured!'
+ end
+
+ should "be able to vote down" do
+ vote_down
+ assert_equal 1, @proposal.votes_against
+ i_am_alerted 'Thank you for casting your vote. Your vote has been captured!'
+ end
+
+ context 'who has already voted for the proposal' do
+ setup do
+ @me.vote_for(@proposal)
+ visit proposal_path(@proposal)
+ end
+
+ should "see a message informing me about what I have voted" do
+ assert page.has_content?('You have already voted up this proposal.')
+ end
+
+ should "be able to withdraw my vote" do
+ click_link 'Changed your mind?'
+ vote_clear
+ assert_equal 0, @proposal.votes_for
+ assert_equal 0, @proposal.votes_against
+ i_am_alerted 'Your vote has been cleared. Remember to come back to vote again once you are sure!'
+ end
+
+ should "be able to change my mind" do
+ click_link 'Changed your mind?'
+ vote_down
+ assert_equal 0, @proposal.votes_for
+ assert_equal 1, @proposal.votes_against
+ i_am_alerted 'Thank you for casting your vote. Your vote has been captured!'
+ end
+ end
+ end
+
+ context "a proposer viewing their proposal" do
+ setup do
+ sign_in @proposer
+ visit proposal_path(@proposal)
+ end
- should "be able to vote up a proposal" do
- vote_up
- assert_equal 1, @proposal.votes_for
- i_am_alerted 'Thank you for casting your vote. Your vote has been captured!'
+ should "not see a call to action asking to vote for the proposal" do
+ refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :up)}']")
+ refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :down)}']")
+ end
+ end
end
+ end
+ end
- should "be able to vote down" do
- vote_down
- assert_equal 1, @proposal.votes_against
- i_am_alerted 'Thank you for casting your vote. Your vote has been captured!'
+ [Phase.all - [Phase::ONE, Phase::INTERLUDE]].flatten.each do |phase|
+ context "During '#{phase.name}'" do
+ setup do
+ Phase.stubs(:current).returns(phase)
end
- context 'who has already voted for the proposal' do
+ context "Given a talk proposal" do
setup do
- @me.vote_for(@proposal)
- visit proposal_path(@proposal)
+ @proposer = FactoryGirl.create(:user)
+ @proposal = FactoryGirl.create(:proposal, :proposer => @proposer)
end
- should "see a message informing me about what I have voted" do
- assert page.has_content?('You have already voted up this proposal.')
- end
+ context "a visitor viewing the proposal" do
+ setup do
+ visit proposal_path(@proposal)
+ end
- should "be able to withdraw my vote" do
- click_link 'Changed your mind?'
- vote_clear
- assert_equal 0, @proposal.votes_for
- assert_equal 0, @proposal.votes_against
- i_am_alerted 'Your vote has been cleared. Remember to come back to vote again once you are sure!'
+ should "not be able to vote anything" do
+ refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :up)}']")
+ refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :down)}']")
+ end
end
- should "be able to change my mind" do
- click_link 'Changed your mind?'
- vote_down
- assert_equal 0, @proposal.votes_for
- assert_equal 1, @proposal.votes_against
- i_am_alerted 'Thank you for casting your vote. Your vote has been captured!'
+ context "a logged in user viewing the proposal" do
+ setup do
+ @me = FactoryGirl.create(:user)
+ sign_in @me
+ visit proposal_path(@proposal)
+ end
+
+ should "not be able to vote anything" do
+ refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :up)}']")
+ refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :down)}']")
+ end
+
+ context 'who has already voted for the proposal' do
+ setup do
+ @me.vote_for(@proposal)
+ visit proposal_path(@proposal)
+ end
+
+ should "not see a message informing me about what I have voted" do
+ assert !page.has_content?('You have already voted up this proposal.')
+ end
+
+ should "not be able to vote anything" do
+ refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :up)}']")
+ refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :down)}']")
+ end
+ end
end
- end
- end
- context "a proposer viewing their proposal" do
- setup do
- sign_in @proposer
- visit proposal_path(@proposal)
- end
+ context "a proposer viewing their proposal" do
+ setup do
+ sign_in @proposer
+ visit proposal_path(@proposal)
+ end
- should "not see a call to action asking to vote for the proposal" do
- refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :up)}']")
- refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :down)}']")
+ should "not see a call to action asking to vote for the proposal" do
+ refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :up)}']")
+ refute page.has_css?("a[href='#{vote_proposal_path(@proposal, :vote => :down)}']")
+ end
+ end
end
end
end
diff --git a/test/integration/reason_test.rb b/test/integration/reason_test.rb
index a9b8a96..0e3f27f 100644
--- a/test/integration/reason_test.rb
+++ b/test/integration/reason_test.rb
@@ -1,40 +1,46 @@
require 'test_helper'
class ReasonTest < IntegrationTestCase
- context "When signing in after registering without having supplied a reason" do
- setup do
- Settings['event_name'] = 'Event name'
- @user = FactoryGirl.create(:user, :signup_reason => nil)
- sign_in @user
- end
-
- should "tell the user that they haven't stated a reason for siging up" do
- assert has_content?("Other attendees are wondering what you hope to get out of Event name.")
- end
-
- context "be able to provide a reason now" do
+ [Phase::ZERO, Phase::ONE].each do |phase|
+ context "During '#{phase.name}'" do
setup do
- click_link "Tell them now"
+ Phase.stubs(:current).returns(phase)
end
- should %Q{not show the "you haven't added a reason" message} do
- assert !has_content?("Other attendees are wondering what you hope to get out of Event name.")
- end
-
- context "be able to provide their sign up reason" do
+ context "When signing in after registering without having supplied a reason" do
setup do
- fill_in "user_signup_reason", :with => "I have signed up because I want to help shape the content"
- click_button "Save"
+ Settings['event_name'] = 'Event name'
+ @user = FactoryGirl.create(:user, :signup_reason => nil)
+ sign_in @user
end
- should "show new sign up reason" do
- assert has_css?("#signup_reason", :text => "I have signed up because I want to help shape the content")
+ should "tell the user that they haven't stated a reason for siging up" do
+ assert has_content?("Other attendees are wondering what you hope to get out of Event name.")
end
- end
- context "be able to provide their sign up reason and preserve markdown syntax" do
- setup do
- fill_in "user_signup_reason", :with => %{
+ context "be able to provide a reason now" do
+ setup do
+ click_link "Tell them now"
+ end
+
+ should %Q{not show the "you haven't added a reason" message} do
+ assert !has_content?("Other attendees are wondering what you hope to get out of Event name.")
+ end
+
+ context "be able to provide their sign up reason" do
+ setup do
+ fill_in "user_signup_reason", :with => "I have signed up because I want to help shape the content"
+ click_button "Save"
+ end
+
+ should "show new sign up reason" do
+ assert has_css?("#signup_reason", :text => "I have signed up because I want to help shape the content")
+ end
+ end
+
+ context "be able to provide their sign up reason and preserve markdown syntax" do
+ setup do
+ fill_in "user_signup_reason", :with => %{
## Me
I like hacking on non-rails ruby stuff
@@ -43,35 +49,57 @@ class ReasonTest < IntegrationTestCase
I want to make sure that the talks cover something *other* than rails!!
}
- click_button "Save"
- end
+ click_button "Save"
+ end
+
+ should "show new sign up reason" do
+ within("#signup_reason") do
+ assert page.has_css?('h2', :text => "Me")
+ assert page.has_css?('p', :text => 'I like hacking on non-rails ruby stuff')
+ assert page.has_css?('h2', :text => "Why I've signed up")
+ assert page.has_css?('p', :text => 'I want to make sure that the talks cover something other than rails!!')
+ end
+ end
- should "show new sign up reason" do
- within("#signup_reason") do
- assert page.has_css?('h2', :text => "Me")
- assert page.has_css?('p', :text => 'I like hacking on non-rails ruby stuff')
- assert page.has_css?('h2', :text => "Why I've signed up")
- assert page.has_css?('p', :text => 'I want to make sure that the talks cover something other than rails!!')
+ should "allow the user to go back and edit their reason" do
+ click_link 'Edit your profile'
+
+ i_am_on edit_user_path(@user)
+ end
end
end
+ end
- should "allow the user to go back and edit their reason" do
- click_link 'Edit your profile'
+ context "When signing in after registering when they have supplied a reason" do
+ setup do
+ user = FactoryGirl.create(:user)
+ sign_in user
+ end
- i_am_on edit_user_path(@user)
+ should "not tell the user that they haven't stated a reason for siging up" do
+ assert !has_content?("Other attendees are wondering what you hope to get out of Event name.")
end
end
end
end
- context "When signing in after registering when they have supplied a reason" do
- setup do
- user = FactoryGirl.create(:user)
- sign_in user
- end
+ [Phase.all - [Phase::ZERO, Phase::ONE]].flatten.each do |phase|
+ context "During '#{phase.name}'" do
+ setup do
+ Phase.stubs(:current).returns(phase)
+ end
- should "not tell the user that they haven't stated a reason for siging up" do
- assert !has_content?("Other attendees are wondering what you hope to get out of Event name.")
+ context "When signing in after registering without having supplied a reason" do
+ setup do
+ Settings['event_name'] = 'Event name'
+ @user = FactoryGirl.create(:user, :signup_reason => nil)
+ sign_in @user
+ end
+
+ should "not tell the user that they haven't stated a reason for siging up" do
+ refute has_content?("Other attendees are wondering what you hope to get out of Event name.")
+ end
+ end
end
end
end
diff --git a/test/unit/phase_test.rb b/test/unit/phase_test.rb
new file mode 100644
index 0000000..46c421b
--- /dev/null
+++ b/test/unit/phase_test.rb
@@ -0,0 +1,197 @@
+require "test_helper"
+
+class PhaseTest < ActiveSupport::TestCase
+ context "Phase selection" do
+ should "select zero before 28th of March" do
+ Timecop.freeze(DateTime.parse('2013-03-27T00:00:00+2')) do
+ assert_equal Phase::ZERO, Phase.current
+ end
+ end
+
+ should "select one on 28th of March" do
+ Timecop.freeze(DateTime.parse('2013-03-28T00:00:00+2')) do
+ assert_equal Phase::ONE, Phase.current
+ end
+ end
+
+ should "select interlude on 24th of April" do
+ Timecop.freeze(DateTime.parse('2013-04-24T00:00:00+3')) do
+ assert_equal Phase::INTERLUDE, Phase.current
+ end
+ end
+
+ should "select two on 29th of April" do
+ Timecop.freeze(DateTime.parse('2013-04-29T00:00:00+3')) do
+ assert_equal Phase::TWO, Phase.current
+ end
+ end
+
+ should "select confirmation on 6th of May" do
+ Timecop.freeze(DateTime.parse('2013-05-06T00:00:00+3')) do
+ assert_equal Phase::CONFIRMATION, Phase.current
+ end
+ end
+
+ should "select lineup on 9th of May" do
+ Timecop.freeze(DateTime.parse('2013-05-09T00:00:00+3')) do
+ assert_equal Phase::LINEUP, Phase.current
+ end
+ end
+ end
+
+ context "Phase zero" do
+ setup do
+ @phase = Phase::ZERO
+ end
+
+ should "not allow new submissions" do
+ assert !@phase.new_submissions_allowed?
+ end
+
+ should "not allow submission editing" do
+ assert !@phase.submission_editing_allowed?
+ end
+
+ should "not allow new suggestions" do
+ assert !@phase.new_suggestions_allowed?
+ end
+
+ should "not allow voting" do
+ assert !@phase.voting_allowed?
+ end
+
+ should "not allow submission withdrawal" do
+ assert !@phase.submission_withdrawal_allowed?
+ end
+ end
+
+ context "Phase one" do
+ setup do
+ @phase = Phase::ONE
+ end
+
+ should "allow new submissions" do
+ assert @phase.new_submissions_allowed?
+ end
+
+ should "allow submission editing" do
+ assert @phase.submission_editing_allowed?
+ end
+
+ should "allow new suggestions" do
+ assert @phase.new_suggestions_allowed?
+ end
+
+ should "allow voting" do
+ assert @phase.voting_allowed?
+ end
+
+ should "allow submission withdrawal" do
+ assert @phase.submission_withdrawal_allowed?
+ end
+ end
+
+ context "Interlude" do
+ setup do
+ @phase = Phase::INTERLUDE
+ end
+
+ should "not allow new submissions" do
+ assert !@phase.new_submissions_allowed?
+ end
+
+ should "not allow submission editing" do
+ assert !@phase.submission_editing_allowed?
+ end
+
+ should "not allow new suggestions" do
+ assert !@phase.new_suggestions_allowed?
+ end
+
+ should "allow voting" do
+ assert @phase.voting_allowed?
+ end
+
+ should "allow submission withdrawal" do
+ assert @phase.submission_withdrawal_allowed?
+ end
+ end
+
+ context "Phase two" do
+ setup do
+ @phase = Phase::TWO
+ end
+
+ should "not allow new submissions" do
+ assert !@phase.new_submissions_allowed?
+ end
+
+ should "not allow submission editing" do
+ assert !@phase.submission_editing_allowed?
+ end
+
+ should "not allow new suggestions" do
+ assert !@phase.new_suggestions_allowed?
+ end
+
+ should "not allow voting" do
+ assert !@phase.voting_allowed?
+ end
+
+ should "allow submission withdrawal" do
+ assert @phase.submission_withdrawal_allowed?
+ end
+ end
+
+ context "Confirmation" do
+ setup do
+ @phase = Phase::CONFIRMATION
+ end
+
+ should "not allow new submissions" do
+ assert !@phase.new_submissions_allowed?
+ end
+
+ should "not allow submission editing" do
+ assert !@phase.submission_editing_allowed?
+ end
+
+ should "not allow new suggestions" do
+ assert !@phase.new_suggestions_allowed?
+ end
+
+ should "not allow voting" do
+ assert !@phase.voting_allowed?
+ end
+
+ should "allow submission withdrawal" do
+ assert @phase.submission_withdrawal_allowed?
+ end
+ end
+
+ context "Lineup" do
+ setup do
+ @phase = Phase::LINEUP
+ end
+
+ should "not allow new submissions" do
+ assert !@phase.new_submissions_allowed?
+ end
+
+ should "not allow submission editing" do
+ assert !@phase.submission_editing_allowed?
+ end
+
+ should "not allow new suggestions" do
+ assert !@phase.new_suggestions_allowed?
+ end
+
+ should "not allow voting" do
+ assert !@phase.voting_allowed?
+ end
+
+ should "not allow submission withdrawal" do
+ assert !@phase.submission_withdrawal_allowed?
+ end
+ end
+end