Commit f24b02c363cc123bd898ce1735d7e849f27a8445
1 parent
798398d0
Exists in
master
and in
22 other branches
ActionItem41: dropping the listing of random people for now
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1339 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
4 additions
and
25 deletions
Show diff stats
app/models/profile_list_block.rb
| ... | ... | @@ -7,17 +7,8 @@ class ProfileListBlock < Block |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | 9 | def profiles |
| 10 | - top = Profile.count | |
| 11 | - | |
| 12 | - result = [] | |
| 13 | - maxsize = [limit,top].compact.min | |
| 14 | - | |
| 15 | - maxsize.times do | |
| 16 | - profile = Profile.find(random(top) + 1) | |
| 17 | - result << profile | |
| 18 | - end | |
| 19 | - | |
| 20 | - result | |
| 10 | + # FIXME pick random people instead | |
| 11 | + Profile.find(:all, :limit => self.limit, :order => 'created_at desc') | |
| 21 | 12 | end |
| 22 | 13 | |
| 23 | 14 | def random(top) |
| ... | ... | @@ -27,7 +18,7 @@ class ProfileListBlock < Block |
| 27 | 18 | def content |
| 28 | 19 | profiles = self.profiles |
| 29 | 20 | lambda do |
| 30 | - block_title(_('People')) + | |
| 21 | + block_title(_('People and Groups')) + | |
| 31 | 22 | profiles.map {|item| content_tag('div', profile_image_link(item)) }.join("\n") |
| 32 | 23 | end |
| 33 | 24 | end | ... | ... |
test/unit/profile_list_block_test.rb
| ... | ... | @@ -40,19 +40,7 @@ class ProfileListBlockTest < Test::Unit::TestCase |
| 40 | 40 | assert_kind_of String, instance_eval(&block.content) |
| 41 | 41 | end |
| 42 | 42 | |
| 43 | - should 'pick random people' do | |
| 44 | - block = ProfileListBlock.new | |
| 45 | - | |
| 46 | - Profile.expects(:count).returns(3) | |
| 47 | - | |
| 48 | - block.expects(:random).times(3).returns(7).then.returns(4).then.returns(5) | |
| 49 | - | |
| 50 | - Profile.expects(:find).with(8) | |
| 51 | - Profile.expects(:find).with(5) | |
| 52 | - Profile.expects(:find).with(6) | |
| 53 | - | |
| 54 | - block.profiles | |
| 55 | - end | |
| 43 | + should 'pick random people' | |
| 56 | 44 | |
| 57 | 45 | should 'use Kernel.rand to generate random numbers' do |
| 58 | 46 | Kernel.expects(:rand).with(77).once | ... | ... |