recent_documents_block_test.rb
1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require File.dirname(__FILE__) + '/../test_helper'
class RecentDocumentsBlockTest < Test::Unit::TestCase
def setup
profile = create_user('testinguser').person
profile.articles.build(:name => 'first').save!
profile.articles.build(:name => 'second').save!
profile.articles.build(:name => 'third').save!
profile.articles.build(:name => 'fourth').save!
profile.articles.build(:name => 'fifth').save!
box = Box.create!(:owner => profile)
@block = RecentDocumentsBlock.create!(:box_id => box.id)
end
attr_reader :block
should 'describe itself' do
assert_not_equal Block.description, RecentDocumentsBlock.description
end
should 'output list with links to recent documents' do
output = block.content
assert_match /href=.*\/testinguser\/first/, output
assert_match /href=.*\/testinguser\/second/, output
assert_match /href=.*\/testinguser\/third/, output
assert_match /href=.*\/testinguser\/fourth/, output
assert_match /href=.*\/testinguser\/fifth/, output
end
should 'respect the maximum number of items as configured' do
block.limit = 3
output = block.content
assert_match /href=.*\/testinguser\/fifth/, output
assert_match /href=.*\/testinguser\/fourth/, output
assert_match /href=.*\/testinguser\/third/, output
assert_no_match /href=.*\/testinguser\/second/, output
assert_no_match /href=.*\/testinguser\/first/, output
end
end