diff --git a/app/models/person.rb b/app/models/person.rb index df0b484..986f1e5 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -229,6 +229,7 @@ class Person < Profile has_and_belongs_to_many :refused_communities, :class_name => 'Community', :join_table => 'refused_join_community' def ask_to_join?(community) + return false if !community.public_profile return false if memberships.include?(community) return false if AddMember.find(:first, :conditions => {:requestor_id => self.id, :target_id => community.id}) !refused_communities.include?(community) diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index 1e26eaa..4dbaa98 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -534,4 +534,10 @@ class PersonTest < Test::Unit::TestCase assert !p.ask_to_join?(c) end + should 'not ask to join if community is not public' do + p = create_user('test_user').person + c = Community.create!(:name => 'Test community', :identifier => 'test_community', :public_profile => false) + + assert !p.ask_to_join?(c) + end end -- libgit2 0.21.2