diff --git a/app/models/profile_list_block.rb b/app/models/profile_list_block.rb index 7b88ac3..cb49e20 100644 --- a/app/models/profile_list_block.rb +++ b/app/models/profile_list_block.rb @@ -7,17 +7,8 @@ class ProfileListBlock < Block end def profiles - top = Profile.count - - result = [] - maxsize = [limit,top].compact.min - - maxsize.times do - profile = Profile.find(random(top) + 1) - result << profile - end - - result + # FIXME pick random people instead + Profile.find(:all, :limit => self.limit, :order => 'created_at desc') end def random(top) @@ -27,7 +18,7 @@ class ProfileListBlock < Block def content profiles = self.profiles lambda do - block_title(_('People')) + + block_title(_('People and Groups')) + profiles.map {|item| content_tag('div', profile_image_link(item)) }.join("\n") end end diff --git a/test/unit/profile_list_block_test.rb b/test/unit/profile_list_block_test.rb index 2a385fd..e6761d0 100644 --- a/test/unit/profile_list_block_test.rb +++ b/test/unit/profile_list_block_test.rb @@ -40,19 +40,7 @@ class ProfileListBlockTest < Test::Unit::TestCase assert_kind_of String, instance_eval(&block.content) end - should 'pick random people' do - block = ProfileListBlock.new - - Profile.expects(:count).returns(3) - - block.expects(:random).times(3).returns(7).then.returns(4).then.returns(5) - - Profile.expects(:find).with(8) - Profile.expects(:find).with(5) - Profile.expects(:find).with(6) - - block.profiles - end + should 'pick random people' should 'use Kernel.rand to generate random numbers' do Kernel.expects(:rand).with(77).once -- libgit2 0.21.2