[Git][noosfero/noosfero][master] 2 commits: display activities of communities for visitors
Leandro Nunes
gitlab at mg.gitlab.com
Thu Feb 23 14:48:48 BRT 2017
Leandro Nunes pushed to branch master at Noosfero / noosfero
Commits:
866f91d5 by Leandro Nunes dos Santos at 2017-02-23T10:52:49-03:00
display activities of communities for visitors
- - - - -
1c00bec6 by Leandro Nunes dos Santos at 2017-02-23T14:48:22-03:00
Merge branch 'noosferogov/noosfero-display_activities_community'
- - - - -
2 changed files:
- app/models/menu_block.rb
- test/unit/menu_block_test.rb
Changes:
=====================================
app/models/menu_block.rb
=====================================
--- a/app/models/menu_block.rb
+++ b/app/models/menu_block.rb
@@ -40,7 +40,11 @@ class MenuBlock < Block
end
def display_activities?(user)
- AccessLevels.can_access?(owner.wall_access, user, owner)
+ AccessLevels.can_access?(access_level, user, owner)
+ end
+
+ def access_level
+ owner.person? ? AccessLevels::LEVELS[:users] : AccessLevels::LEVELS[:visitors]
end
def display_about?(user)
=====================================
test/unit/menu_block_test.rb
=====================================
--- a/test/unit/menu_block_test.rb
+++ b/test/unit/menu_block_test.rb
@@ -18,11 +18,6 @@ class MenuBlockTest < ActiveSupport::TestCase
assert block.editable?
end
- should 'return empty in enabled links for community when not logged in' do
- links = block.enabled_links(nil)
- assert_equal 0, links.size
- end
-
should 'return only about link for person when not logged in' do
block.box = create(Box, owner: fast_create(Person))
links = block.enabled_links(nil)
@@ -30,10 +25,22 @@ class MenuBlockTest < ActiveSupport::TestCase
assert_equal 'About', links.first[:title]
end
- should 'return only about link for community when user has no permission' do
+ should 'return activities link for community when user has no permission' do
links = block.enabled_links(person)
- assert_equal 1, links.size
- assert_equal 'Activities', links.first[:title]
+ assert links.detect{|link| link[:title] == 'Activities' }
+ end
+
+ should 'return activities link for community for visitors' do
+ links = block.enabled_links(nil)
+ assert links.detect{|link| link[:title] == 'Activities' }
+ end
+
+ should 'not return activities link for person visitors' do
+ person = fast_create(Person)
+ box = create(Box, owner: person)
+ block = MenuBlock.new(box: box)
+ links = block.enabled_links(nil)
+ assert !links.detect{|link| link[:title] == 'Activities' }
end
should 'return all community links for an owner' do
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/71626a47a2b482b290836fcd5ace167f7f09a73a...1c00bec6021c1ab443a50872b5b8ccfaf21675f0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170223/9045cf0c/attachment-0001.html>
More information about the Noosfero-dev
mailing list