From 719df8619d3b25fc7ade546dfedc21b336dbae33 Mon Sep 17 00:00:00 2001 From: Nikos Dimitrakopoulos Date: Sun, 21 Apr 2013 22:46:15 +0300 Subject: [PATCH] Don't show notification to edit signup reason after Phase 1. Refs #15. --- app/helpers/application_helper.rb | 2 +- test/integration/reason_test.rb | 116 ++++++++++++++++++------------ 2 files changed, 73 insertions(+), 45 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 092a74e..fcdc1a1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -33,7 +33,7 @@ def remind_account_for_tickets end def remind_account_for_signup_reason - current_user && !current_user.signup_reason.present? && !request.path[/user/] && can?(:edit, current_user) + current_phase.in?(Phase::ZERO, Phase::ONE) && current_user && !current_user.signup_reason.present? && !request.path[/user/] && can?(:edit, current_user) end def avatar_url(user, bigger=false) 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