diff --git a/app/models/profile_list_block.rb b/app/models/profile_list_block.rb index a7b4122..ab101d1 100644 --- a/app/models/profile_list_block.rb +++ b/app/models/profile_list_block.rb @@ -16,19 +16,19 @@ class ProfileListBlock < Block def profile_list result = nil - visible_profiles = profiles.visible.includes([:image,:domains,:preferred_domain,:environment]) + public_profiles = profiles.public.includes([:image,:domains,:preferred_domain,:environment]) if !prioritize_profiles_with_image - result = visible_profiles.all(:limit => get_limit, :order => 'profiles.updated_at DESC').sort_by{ rand } +result = public_profiles.all(:limit => get_limit, :order => 'profiles.updated_at DESC').sort_by{ rand } elsif profiles.visible.with_image.count >= get_limit - result = visible_profiles.with_image.all(:limit => get_limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand } + result = public_profiles.with_image.all(:limit => get_limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand } else - 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 } + 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 } end result.slice(0..get_limit-1) end def profile_count - profiles.visible.length + profiles.public.length end # the title of the block. Probably will be overriden in subclasses. diff --git a/test/unit/profile_list_block_test.rb b/test/unit/profile_list_block_test.rb index 2f5b3f8..a5af4dd 100644 --- a/test/unit/profile_list_block_test.rb +++ b/test/unit/profile_list_block_test.rb @@ -77,7 +77,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase block.save! assert_equal 'Title from block', block.view_title end - + should 'provide view title with variables' do env = fast_create(Environment) env.boxes << Box.new @@ -87,7 +87,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase assert_equal '0 members', block.view_title end - should 'count number of public and private profiles' do + should 'count number of only public profiles' do env = fast_create(Environment) env.boxes << Box.new block = ProfileListBlock.new @@ -103,7 +103,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase priv_e = fast_create(Enterprise, :public_profile => false , :environment_id => env.id) pub_e = fast_create(Enterprise, :public_profile => true , :environment_id => env.id) - assert_equal 6, block.profile_count + assert_equal 3, block.profile_count end should 'only count number of visible profiles' do -- libgit2 0.21.2