Commit 0999076c888067eed97a885dc8f70aa9f6568860
1 parent
ae30560e
Exists in
master
and in
29 other branches
ActionItem443: not listing private communities in communities block
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2292 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
19 additions
and
4 deletions
Show diff stats
app/models/communities_block.rb
| ... | ... | @@ -36,7 +36,7 @@ class CommunitiesBlock < ProfileListBlock |
| 36 | 36 | def ids |
| 37 | 37 | # FIXME when owner is an environment (i.e. listing communities globally |
| 38 | 38 | # this can become SLOW) |
| 39 | - block.owner.communities.map(&:id) | |
| 39 | + block.owner.communities.select(&:public_profile).map(&:id) | |
| 40 | 40 | end |
| 41 | 41 | end |
| 42 | 42 | ... | ... |
test/unit/communities_block_test.rb
| ... | ... | @@ -27,9 +27,9 @@ class CommunitiesBlockTest < Test::Unit::TestCase |
| 27 | 27 | owner = mock |
| 28 | 28 | block.expects(:owner).returns(owner) |
| 29 | 29 | |
| 30 | - member1 = mock; member1.stubs(:id).returns(1) | |
| 31 | - member2 = mock; member2.stubs(:id).returns(2) | |
| 32 | - member3 = mock; member3.stubs(:id).returns(3) | |
| 30 | + member1 = mock; member1.stubs(:id).returns(1); member1.stubs(:public_profile).returns(true) | |
| 31 | + member2 = mock; member2.stubs(:id).returns(2); member2.stubs(:public_profile).returns(true) | |
| 32 | + member3 = mock; member3.stubs(:id).returns(3); member3.stubs(:public_profile).returns(true) | |
| 33 | 33 | |
| 34 | 34 | owner.expects(:communities).returns([member1, member2, member3]) |
| 35 | 35 | |
| ... | ... | @@ -71,4 +71,19 @@ class CommunitiesBlockTest < Test::Unit::TestCase |
| 71 | 71 | assert_equal '', block.footer |
| 72 | 72 | end |
| 73 | 73 | |
| 74 | + should 'not list non-public communities' do | |
| 75 | + user = create_user('testuser').person | |
| 76 | + | |
| 77 | + public_community = Community.create!(:name => 'test community 1', :identifier => 'comm1', :environment => Environment.default) | |
| 78 | + public_community.add_member(user) | |
| 79 | + | |
| 80 | + private_community = Community.create!(:name => 'test community 2', :identifier => 'comm2', :environment => Environment.default, :public_profile => false) | |
| 81 | + private_community.add_member(user) | |
| 82 | + | |
| 83 | + block = CommunitiesBlock.new | |
| 84 | + block.expects(:owner).returns(user) | |
| 85 | + | |
| 86 | + assert_equal [public_community], block.profiles | |
| 87 | + end | |
| 88 | + | |
| 74 | 89 | end | ... | ... |