Commit 9f25380720013b83ff64a484856f537aa8a8cbe9

Authored by Braulio Bhavamitra
2 parents fea4d5ef bc24852b

Merge branch 'blogoosfero258' into noosfero

app/models/profile_list_block.rb
... ... @@ -16,19 +16,19 @@ class ProfileListBlock < Block
16 16  
17 17 def profile_list
18 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 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 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 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 26 end
27 27 result.slice(0..get_limit-1)
28 28 end
29 29  
30 30 def profile_count
31   - profiles.visible.length
  31 + profiles.public.length
32 32 end
33 33  
34 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 77 block.save!
78 78 assert_equal 'Title from block', block.view_title
79 79 end
80   -
  80 +
81 81 should 'provide view title with variables' do
82 82 env = fast_create(Environment)
83 83 env.boxes << Box.new
... ... @@ -87,7 +87,7 @@ class ProfileListBlockTest &lt; ActiveSupport::TestCase
87 87 assert_equal '0 members', block.view_title
88 88 end
89 89  
90   - should 'count number of public and private profiles' do
  90 + should 'count number of only public profiles' do
91 91 env = fast_create(Environment)
92 92 env.boxes << Box.new
93 93 block = ProfileListBlock.new
... ... @@ -103,7 +103,7 @@ class ProfileListBlockTest &lt; ActiveSupport::TestCase
103 103 priv_e = fast_create(Enterprise, :public_profile => false , :environment_id => env.id)
104 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 107 end
108 108  
109 109 should 'only count number of visible profiles' do
... ...