Commit 4d1e4b41c4012fc2535f36184901de32cabfca75

Authored by Antonio Terceiro
1 parent 7afb8e5a

ActionItem959: use the session info even if logged in

app/helpers/application_helper.rb
@@ -777,11 +777,14 @@ module ApplicationHelper @@ -777,11 +777,14 @@ module ApplicationHelper
777 def ask_to_join? 777 def ask_to_join?
778 return if environment.enabled?(:disable_join_community_popup) 778 return if environment.enabled?(:disable_join_community_popup)
779 return unless profile && profile.kind_of?(Community) 779 return unless profile && profile.kind_of?(Community)
780 - unless logged_in?  
781 - return !session[:no_asking].include?(profile.id) if session[:no_asking]  
782 - return true 780 + if (session[:no_asking] && session[:no_asking].include?(profile.id))
  781 + return false
  782 + end
  783 + if logged_in?
  784 + user.ask_to_join?(profile)
  785 + else
  786 + true
783 end 787 end
784 - user.ask_to_join?(profile)  
785 end 788 end
786 789
787 end 790 end
test/unit/application_helper_test.rb
@@ -433,6 +433,19 @@ class ApplicationHelperTest < Test::Unit::TestCase @@ -433,6 +433,19 @@ class ApplicationHelperTest < Test::Unit::TestCase
433 assert !ask_to_join? 433 assert !ask_to_join?
434 end 434 end
435 435
  436 + should 'not ask_to_join if its recorded in the session even for authenticated users' do
  437 + e = Environment.default
  438 + e.stubs(:enabled?).with(:disable_join_community_popup).returns(false)
  439 + stubs(:environment).returns(e)
  440 +
  441 + c = Community.create(:name => 'test_comm', :identifier => 'test_comm')
  442 + stubs(:profile).returns(c)
  443 + stubs(:logged_in?).returns(true)
  444 + stubs(:session).returns({:no_asking => [c.id]})
  445 +
  446 + assert !ask_to_join?
  447 + end
  448 +
436 protected 449 protected
437 450
438 def url_for(args = {}) 451 def url_for(args = {})