Commit 9f25380720013b83ff64a484856f537aa8a8cbe9
Exists in
master
and in
29 other branches
Merge branch 'blogoosfero258' into noosfero
Showing
2 changed files
with
8 additions
and
8 deletions
Show diff stats
app/models/profile_list_block.rb
@@ -16,19 +16,19 @@ class ProfileListBlock < Block | @@ -16,19 +16,19 @@ class ProfileListBlock < Block | ||
16 | 16 | ||
17 | def profile_list | 17 | def profile_list |
18 | result = nil | 18 | result = nil |
19 | - visible_profiles = profiles.visible.includes([:image,:domains,:preferred_domain,:environment]) | 19 | + public_profiles = profiles.public.includes([:image,:domains,:preferred_domain,:environment]) |
20 | if !prioritize_profiles_with_image | 20 | if !prioritize_profiles_with_image |
21 | - result = visible_profiles.all(:limit => get_limit, :order => 'profiles.updated_at DESC').sort_by{ rand } | 21 | +result = public_profiles.all(:limit => get_limit, :order => 'profiles.updated_at DESC').sort_by{ rand } |
22 | elsif profiles.visible.with_image.count >= get_limit | 22 | elsif profiles.visible.with_image.count >= get_limit |
23 | - result = visible_profiles.with_image.all(:limit => get_limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand } | 23 | + result = public_profiles.with_image.all(:limit => get_limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand } |
24 | else | 24 | else |
25 | - result = visible_profiles.with_image.sort_by{ rand } + visible_profiles.without_image.all(:limit => get_limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand } | 25 | + result = public_profiles.with_image.sort_by{ rand } + public_profiles.without_image.all(:limit => get_limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand } |
26 | end | 26 | end |
27 | result.slice(0..get_limit-1) | 27 | result.slice(0..get_limit-1) |
28 | end | 28 | end |
29 | 29 | ||
30 | def profile_count | 30 | def profile_count |
31 | - profiles.visible.length | 31 | + profiles.public.length |
32 | end | 32 | end |
33 | 33 | ||
34 | # the title of the block. Probably will be overriden in subclasses. | 34 | # the title of the block. Probably will be overriden in subclasses. |
test/unit/profile_list_block_test.rb
@@ -77,7 +77,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase | @@ -77,7 +77,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase | ||
77 | block.save! | 77 | block.save! |
78 | assert_equal 'Title from block', block.view_title | 78 | assert_equal 'Title from block', block.view_title |
79 | end | 79 | end |
80 | - | 80 | + |
81 | should 'provide view title with variables' do | 81 | should 'provide view title with variables' do |
82 | env = fast_create(Environment) | 82 | env = fast_create(Environment) |
83 | env.boxes << Box.new | 83 | env.boxes << Box.new |
@@ -87,7 +87,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase | @@ -87,7 +87,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase | ||
87 | assert_equal '0 members', block.view_title | 87 | assert_equal '0 members', block.view_title |
88 | end | 88 | end |
89 | 89 | ||
90 | - should 'count number of public and private profiles' do | 90 | + should 'count number of only public profiles' do |
91 | env = fast_create(Environment) | 91 | env = fast_create(Environment) |
92 | env.boxes << Box.new | 92 | env.boxes << Box.new |
93 | block = ProfileListBlock.new | 93 | block = ProfileListBlock.new |
@@ -103,7 +103,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase | @@ -103,7 +103,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase | ||
103 | priv_e = fast_create(Enterprise, :public_profile => false , :environment_id => env.id) | 103 | priv_e = fast_create(Enterprise, :public_profile => false , :environment_id => env.id) |
104 | pub_e = fast_create(Enterprise, :public_profile => true , :environment_id => env.id) | 104 | pub_e = fast_create(Enterprise, :public_profile => true , :environment_id => env.id) |
105 | 105 | ||
106 | - assert_equal 6, block.profile_count | 106 | + assert_equal 3, block.profile_count |
107 | end | 107 | end |
108 | 108 | ||
109 | should 'only count number of visible profiles' do | 109 | should 'only count number of visible profiles' do |