[Git][noosfero/noosfero][master] 2 commits: block: always display block to environment admins

Leandro Nunes gitlab at mg.gitlab.com
Mon Jan 22 13:23:05 BRST 2018


Leandro Nunes pushed to branch master at Noosfero / noosfero


Commits:
0a7584e2 by Rodrigo Souto at 2018-01-22T11:41:44-03:00
block: always display block to environment admins

- - - - -
3f06a44c by Leandro Nunes at 2018-01-22T15:22:52+00:00
Merge branch 'show-block-to-admins' into 'master'

block: always display block to environment admins

See merge request noosfero/noosfero!1379
- - - - -


2 changed files:

- app/models/block.rb
- test/unit/block_test.rb


Changes:

=====================================
app/models/block.rb
=====================================
--- a/app/models/block.rb
+++ b/app/models/block.rb
@@ -103,7 +103,7 @@ class Block < ApplicationRecord
   end
 
   def display_to_user?(user)
-    display_user == 'all' || (user.nil? && display_user == 'not_logged') || (user && display_user == 'logged') || (user && !self.owner.kind_of?(Environment) && display_user == 'followers' && owner.in_social_circle?(user) && self.owner.kind_of?(Profile))
+    display_user == 'all' || (environment.present? && environment.admins.include?(user)) || (user.nil? && display_user == 'not_logged') || (user && display_user == 'logged') || (user && !self.owner.kind_of?(Environment) && display_user == 'followers' && owner.in_social_circle?(user) && self.owner.kind_of?(Profile))
   end
 
   def display_always(context)


=====================================
test/unit/block_test.rb
=====================================
--- a/test/unit/block_test.rb
+++ b/test/unit/block_test.rb
@@ -320,6 +320,18 @@ class BlockTest < ActiveSupport::TestCase
     assert block.display_to_user?(user.person)
   end
 
+  should 'display block to environment admins for display_user = members' do
+    community = fast_create(Community)
+    user = create_user('testinguser')
+    community.environment.add_admin(user.person)
+
+    box = fast_create(Box, :owner_id => community.id, :owner_type => 'Community')
+    block = create(Block, :box_id => box.id)
+    block.display_user = 'followers'
+    block.save!
+    assert block.display_to_user?(user.person)
+  end
+
   should 'do not display block to non members of community for display_user = members' do
     community = fast_create(Community)
     user = create_user('testinguser')



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/1a590a768b50ffc527ceef66a2edaec2bc6f8adc...3f06a44c157140d010d989bfe59a47383ed23002

---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/1a590a768b50ffc527ceef66a2edaec2bc6f8adc...3f06a44c157140d010d989bfe59a47383ed23002
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180122/3328329b/attachment-0001.html>


More information about the Noosfero-dev mailing list