Commit f6f306c510141dfe5cd03c0ffb0b7b27dbe7139e
1 parent
ed065de8
Exists in
master
and in
14 other branches
people_block: remove redundant distinct from with_role scope
Showing
2 changed files
with
9 additions
and
1 deletions
Show diff stats
plugins/people_block/lib/ext/person.rb
| @@ -3,7 +3,7 @@ require_dependency 'person' | @@ -3,7 +3,7 @@ require_dependency 'person' | ||
| 3 | class Person | 3 | class Person |
| 4 | 4 | ||
| 5 | scope :with_role, -> role_id { | 5 | scope :with_role, -> role_id { |
| 6 | - select('DISTINCT profiles.*').joins(:role_assignments). | 6 | + joins(:role_assignments). |
| 7 | where("role_assignments.role_id = #{role_id}") | 7 | where("role_assignments.role_id = #{role_id}") |
| 8 | } | 8 | } |
| 9 | 9 |
plugins/people_block/test/unit/members_block_test.rb
| @@ -240,6 +240,10 @@ class MembersBlockTest < ActionView::TestCase | @@ -240,6 +240,10 @@ class MembersBlockTest < ActionView::TestCase | ||
| 240 | 240 | ||
| 241 | assert_includes profiles, profile1 | 241 | assert_includes profiles, profile1 |
| 242 | assert_not_includes profiles, profile2 | 242 | assert_not_includes profiles, profile2 |
| 243 | + | ||
| 244 | + profile_list = block.profile_list | ||
| 245 | + assert_includes profile_list, profile1 | ||
| 246 | + assert_not_includes profile_list, profile2 | ||
| 243 | end | 247 | end |
| 244 | 248 | ||
| 245 | should 'list only profiles with member role' do | 249 | should 'list only profiles with member role' do |
| @@ -261,6 +265,10 @@ class MembersBlockTest < ActionView::TestCase | @@ -261,6 +265,10 @@ class MembersBlockTest < ActionView::TestCase | ||
| 261 | 265 | ||
| 262 | assert_not_includes profiles, profile1 | 266 | assert_not_includes profiles, profile1 |
| 263 | assert_includes profiles, profile2 | 267 | assert_includes profiles, profile2 |
| 268 | + | ||
| 269 | + profile_list = block.profile_list | ||
| 270 | + assert_not_includes profile_list, profile1 | ||
| 271 | + assert_includes profile_list, profile2 | ||
| 264 | end | 272 | end |
| 265 | 273 | ||
| 266 | should 'list available roles' do | 274 | should 'list available roles' do |