diff --git a/app/models/profile_list_block.rb b/app/models/profile_list_block.rb index 456b588..9203ae6 100644 --- a/app/models/profile_list_block.rb +++ b/app/models/profile_list_block.rb @@ -24,7 +24,13 @@ class ProfileListBlock < Block def profiles # FIXME pick random people instead - profile_finder.find(:all, :limit => self.limit, :order => 'created_at desc') + finder = profile_finder + options = { :limit => self.limit, :order => 'created_at desc' } + if finder.is_a?(Class) + finder.find(:all, options) + else + finder.find(options) + end end def random(top) diff --git a/test/unit/profile_list_block_test.rb b/test/unit/profile_list_block_test.rb index 46c7003..1de1d52 100644 --- a/test/unit/profile_list_block_test.rb +++ b/test/unit/profile_list_block_test.rb @@ -47,7 +47,15 @@ class ProfileListBlockTest < Test::Unit::TestCase should 'ask profile finder for profiles' do block = ProfileListBlock.new block.expects(:profile_finder).returns(Profile).once - Profile.expects(:find).returns([]) + Profile.expects(:find).with(:all, is_a(Hash)).returns([]) + block.profiles + end + + should 'support non-class finders' do + block = ProfileListBlock.new + profile = create_user('mytestuser').person + block.expects(:profile_finder).returns(profile.members).once + profile.members.expects(:find).with(is_a(Hash)).once block.profiles end @@ -58,4 +66,5 @@ class ProfileListBlockTest < Test::Unit::TestCase ProfileListBlock.new.random(77) end + end -- libgit2 0.21.2