diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2e008bd..e1c2f9e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -777,11 +777,14 @@ module ApplicationHelper def ask_to_join? return if environment.enabled?(:disable_join_community_popup) return unless profile && profile.kind_of?(Community) - unless logged_in? - return !session[:no_asking].include?(profile.id) if session[:no_asking] - return true + if (session[:no_asking] && session[:no_asking].include?(profile.id)) + return false + end + if logged_in? + user.ask_to_join?(profile) + else + true end - user.ask_to_join?(profile) end end diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index c7ab7d9..c85e635 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -433,6 +433,19 @@ class ApplicationHelperTest < Test::Unit::TestCase assert !ask_to_join? end + should 'not ask_to_join if its recorded in the session even for authenticated users' do + e = Environment.default + e.stubs(:enabled?).with(:disable_join_community_popup).returns(false) + stubs(:environment).returns(e) + + c = Community.create(:name => 'test_comm', :identifier => 'test_comm') + stubs(:profile).returns(c) + stubs(:logged_in?).returns(true) + stubs(:session).returns({:no_asking => [c.id]}) + + assert !ask_to_join? + end + protected def url_for(args = {}) -- libgit2 0.21.2