[Git][noosfero/noosfero][master] 6 commits: Fix to not show person templates on people block
Leandro Nunes
gitlab at mg.gitlab.com
Thu May 11 13:40:46 BRT 2017
Leandro Nunes pushed to branch master at Noosfero / noosfero
Commits:
8b0a0c4a by Josafá Souza Jr at 2017-05-05T10:13:26-03:00
Fix to not show person templates on people block
- - - - -
9812239f by Josafá Souza Jr at 2017-05-09T09:09:16-03:00
Fix to not show person templates on people block
- - - - -
10e0b176 by Evandro Junior at 2017-05-11T10:16:53-03:00
Add tests to filter templates from people block
- - - - -
bb9850f1 by Evandro Junior at 2017-05-11T10:17:19-03:00
Merge branch 'fix-template-person' of https://gitlab.com/noosferogov/noosfero into fix-template-person
- - - - -
128be989 by Evandro Junior at 2017-05-11T10:24:05-03:00
Not add people that are templates to sample data
- - - - -
a05ada49 by Leandro Nunes at 2017-05-11T16:40:36+00:00
Merge branch 'fix-template-person' into 'master'
Fix to not show person templates on people block
See merge request !1197
- - - - -
7 changed files:
- plugins/people_block/lib/friends_block.rb
- plugins/people_block/lib/members_block.rb
- plugins/people_block/lib/people_block.rb
- plugins/people_block/test/unit/friends_block_test.rb
- plugins/people_block/test/unit/members_block_test.rb
- plugins/people_block/test/unit/people_block_test.rb
- script/sample-profiles
Changes:
=====================================
plugins/people_block/lib/friends_block.rb
=====================================
--- a/plugins/people_block/lib/friends_block.rb
+++ b/plugins/people_block/lib/friends_block.rb
@@ -13,7 +13,7 @@ class FriendsBlock < PeopleBlockBase
end
def profiles
- owner.friends
+ owner.friends.no_templates
end
def suggestions
=====================================
plugins/people_block/lib/members_block.rb
=====================================
--- a/plugins/people_block/lib/members_block.rb
+++ b/plugins/people_block/lib/members_block.rb
@@ -17,7 +17,7 @@ class MembersBlock < PeopleBlockBase
end
def profiles
- role ? owner.members.with_role(role.id) : owner.members
+ role ? owner.members.with_role(role.id) : owner.members.no_templates
end
def role
=====================================
plugins/people_block/lib/people_block.rb
=====================================
--- a/plugins/people_block/lib/people_block.rb
+++ b/plugins/people_block/lib/people_block.rb
@@ -13,6 +13,6 @@ class PeopleBlock < PeopleBlockBase
end
def profiles
- owner.people
+ owner.people.no_templates
end
end
=====================================
plugins/people_block/test/unit/friends_block_test.rb
=====================================
--- a/plugins/people_block/test/unit/friends_block_test.rb
+++ b/plugins/people_block/test/unit/friends_block_test.rb
@@ -114,6 +114,17 @@ class FriendsBlockTest < ActionView::TestCase
assert_equivalent block.suggestions, [suggestion1,suggestion2]
end
+ should 'not list templates as friends' do
+ owner = fast_create(Person)
+ friend1 = fast_create(Person)
+ template = fast_create(Person, is_template: true)
+ owner.add_friend(friend1)
+ owner.add_friend(template)
+ block = FriendsBlock.new
+ block.expects(:owner).returns(owner).at_least_once
+ assert_equal 1, block.profile_count
+ end
+
protected
include NoosferoTestHelper
=====================================
plugins/people_block/test/unit/members_block_test.rb
=====================================
--- a/plugins/people_block/test/unit/members_block_test.rb
+++ b/plugins/people_block/test/unit/members_block_test.rb
@@ -372,4 +372,21 @@ class MembersBlockViewTest < ActionView::TestCase
assert_equal 5, json["#"]
end
+ should 'not list templates as community members' do
+ env = fast_create(Environment)
+ env.boxes << Box.new
+ community = fast_create(Community)
+ p1 = fast_create(Person)
+ community.add_member(p1)
+ identifier = "fake_template"
+ template = User.new(:login => identifier, :email => identifier+'@templates.noo', :password => identifier, :password_confirmation => identifier, :person_data => {:name => identifier, :is_template => true}, :environment_id => env.id)
+ template.save!
+ block = MembersBlock.new
+ community.add_member(template.person)
+ block.stubs(:owner).returns(community)
+ env.boxes.first.blocks << block
+ block.save!
+ assert_equal 1, block.profile_list.size
+ end
+
end
=====================================
plugins/people_block/test/unit/people_block_test.rb
=====================================
--- a/plugins/people_block/test/unit/people_block_test.rb
+++ b/plugins/people_block/test/unit/people_block_test.rb
@@ -205,5 +205,14 @@ class PeopleBlockViewTest < ActionView::TestCase
assert_equal 5, json["#"]
end
+ should 'not list person template from environment' do
+ owner = fast_create(Environment)
+ person1 = fast_create(Person, :environment_id => owner.id)
+ person2 = fast_create(Person, :environment_id => owner.id)
+ template = fast_create(Person, :environment_id => owner.id, is_template: true)
+ block = PeopleBlock.new
+ block.expects(:owner).returns(owner).at_least_once
+ assert_equal 2, block.profile_list.count
+ end
end
=====================================
script/sample-profiles
=====================================
--- a/script/sample-profiles
+++ b/script/sample-profiles
@@ -111,7 +111,7 @@ User.where("login NOT LIKE '%%_template'").each do |user|
end
done
-people = $environment.people
+people = $environment.people.no_templates
print "Creating some friendships: "
rand(people.size * 3).times do
from = people.sample
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/73fff1e11d60bb83b5e1a4945d2671238018dc75...a05ada49e2ded0e7d19b79cb78430c90b5bd2cc6
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/73fff1e11d60bb83b5e1a4945d2671238018dc75...a05ada49e2ded0e7d19b79cb78430c90b5bd2cc6
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/20170511/4f1e2907/attachment-0001.html>
More information about the Noosfero-dev
mailing list