folder_test.rb
1.79 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
46
47
48
49
50
51
52
53
54
55
require File.dirname(__FILE__) + '/../test_helper'
class FolderTest < ActiveSupport::TestCase
should 'be an article' do
assert_kind_of Article, Folder.new
end
should 'provide proper description' do
assert_kind_of String, Folder.description
end
should 'provide proper short description' do
assert_kind_of String, Folder.short_description
end
should 'provide own icon name' do
assert_not_equal Article.new.icon_name, Folder.new.icon_name
end
should 'list subitems as HTML content' do
p = create_user('testuser').person
f = Folder.create!(:profile => p, :name => 'f')
f.children.create!(:profile => p, :name => 'onearticle')
f.children.create!(:profile => p, :name => 'otherarticle')
f.reload
assert_tag_in_string f.to_html, :tag => 'td', :descendant => { :tag => 'a', :attributes => { :href => /.*\/testuser\/f\/onearticle$/ } }, :content => /onearticle/
assert_tag_in_string f.to_html, :tag => 'td', :descendant => { :tag => 'a', :attributes => { :href => /.*\/testuser\/f\/otherarticle$/ } }, :content => /otherarticle/
end
should 'explictly advise if empty' do
p = create_user('testuser').person
f = Folder.create!(:profile => p, :name => 'f')
assert_tag_in_string f.to_html, :content => '(empty folder)'
end
should 'show text body in HTML content' do
p = create_user('testuser').person
f = Folder.create!(:name => 'f', :profile => p, :body => 'this-is-the-text')
assert_match(/this-is-the-text/, f.to_html)
end
should 'identify as folder' do
assert Folder.new.folder?, 'folder must identity itself as folder'
end
should 'can display hits' do
profile = create_user('test_user').person
a = Folder.create!(:name => 'Test article', :profile => profile)
assert_equal false, a.can_display_hits?
end
end