Skip to content

Commit

Permalink
Don't show notification to edit signup reason after Phase 1. Refs eur…
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosd committed Apr 21, 2013
1 parent 61c4018 commit 719df86
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 45 deletions.
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
116 changes: 72 additions & 44 deletions test/integration/reason_test.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit 719df86

Please sign in to comment.