boxes_helper_test.rb
2.94 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require File.dirname(__FILE__) + '/../test_helper'
class BoxesHelperTest < Test::Unit::TestCase
include BoxesHelper
include ActionView::Helpers::TagHelper
def setup
@controller = mock
@controller.stubs(:boxes_editor?).returns(false)
@controller.stubs(:uses_design_blocks?).returns(true)
end
should 'include profile-specific header' do
holder = mock
holder.stubs(:boxes).returns([])
holder.stubs(:boxes_limit).returns(0)
holder.stubs(:custom_header_expanded).returns('my custom header')
@controller.stubs(:boxes_holder).returns(holder)
assert_tag_in_string insert_boxes('main content'), :tag => "div", :attributes => { :id => 'profile-header' }, :content => 'my custom header'
end
should 'include profile-specific footer' do
holder = mock
holder.stubs(:boxes).returns([])
holder.stubs(:boxes_limit).returns(0)
holder.stubs(:custom_footer_expanded).returns('my custom footer')
@controller.stubs(:boxes_holder).returns(holder)
assert_tag_in_string insert_boxes('main content'), :tag => "div", :attributes => { :id => 'profile-footer' }, :content => 'my custom footer'
end
def create_user_with_blocks
p = create_user('test_user').person
LinkListBlock.create!(:box => p.boxes.first)
p
end
should 'display invisible block for editing' do
p = create_user_with_blocks
b = p.blocks.select{|bk| !bk.kind_of?(MainBlock) }[0]
b.visible = false; b.save!
box = b.box
box.expects(:blocks).returns([b])
expects(:display_block).with(b, '')
stubs(:block_target).returns('')
with_box_decorator self do
display_box_content(box, '')
end
end
should 'not display invisible block' do
p = create_user_with_blocks
b = p.blocks.select{|bk| !bk.kind_of?(MainBlock) }[0]
b.visible = false; b.save!
box = b.box
box.expects(:blocks).returns([b])
expects(:display_block).with(b, '').never
stubs(:block_target).returns('')
display_box_content(box, '')
end
should 'include profile-specific header without side boxes' do
@controller.stubs(:uses_design_blocks?).returns(false)
holder = mock
holder.stubs(:boxes).returns([])
holder.stubs(:boxes_limit).returns(0)
holder.stubs(:custom_header_expanded).returns('my custom header')
@controller.stubs(:boxes_holder).returns(holder)
assert_tag_in_string insert_boxes('main content'), :tag => "div", :attributes => { :id => 'profile-header' }, :content => 'my custom header'
end
should 'include profile-specific footer without side boxes' do
@controller.stubs(:uses_design_blocks?).returns(false)
holder = mock
holder.stubs(:boxes).returns([])
holder.stubs(:boxes_limit).returns(0)
holder.stubs(:custom_footer_expanded).returns('my custom footer')
@controller.stubs(:boxes_holder).returns(holder)
assert_tag_in_string insert_boxes('main content'), :tag => "div", :attributes => { :id => 'profile-footer' }, :content => 'my custom footer'
end
end