[Git][noosfero/noosfero][master] people_block: remove redundant distinct from with_role scope

Victor Costa gitlab at mg.gitlab.com
Wed Feb 17 17:44:39 BRST 2016


Victor Costa pushed to branch master at Noosfero / noosfero


Commits:
f6f306c5 by Victor Costa at 2016-02-17T16:38:09-03:00
people_block: remove redundant distinct from with_role scope

- - - - -


2 changed files:

- plugins/people_block/lib/ext/person.rb
- plugins/people_block/test/unit/members_block_test.rb


Changes:

=====================================
plugins/people_block/lib/ext/person.rb
=====================================
--- a/plugins/people_block/lib/ext/person.rb
+++ b/plugins/people_block/lib/ext/person.rb
@@ -3,7 +3,7 @@ require_dependency 'person'
 class Person
 
   scope :with_role, -> role_id {
-    select('DISTINCT profiles.*').joins(:role_assignments).
+    joins(:role_assignments).
     where("role_assignments.role_id = #{role_id}")
   }
 


=====================================
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
@@ -240,6 +240,10 @@ class MembersBlockTest < ActionView::TestCase
 
     assert_includes profiles, profile1
     assert_not_includes profiles, profile2
+
+    profile_list = block.profile_list
+    assert_includes profile_list, profile1
+    assert_not_includes profile_list, profile2
   end
 
   should 'list only profiles with member role' do
@@ -261,6 +265,10 @@ class MembersBlockTest < ActionView::TestCase
 
     assert_not_includes profiles, profile1
     assert_includes profiles, profile2
+
+    profile_list = block.profile_list
+    assert_not_includes profile_list, profile1
+    assert_includes profile_list, profile2
   end
 
   should 'list available roles' do



View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/f6f306c510141dfe5cd03c0ffb0b7b27dbe7139e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160217/f46eeb01/attachment.html>


More information about the Noosfero-dev mailing list