Commit 8399cfcb0465fc0a94ae7f130e7bdc21cb951c39
Committed by
Antonio Terceiro
1 parent
2a4c443a
Exists in
master
and in
29 other branches
Fixing and adding tests for Env block (a992dc)
Showing
1 changed file
with
20 additions
and
0 deletions
Show diff stats
test/unit/boxes_helper_test.rb
@@ -39,12 +39,16 @@ class BoxesHelperTest < Test::Unit::TestCase | @@ -39,12 +39,16 @@ class BoxesHelperTest < Test::Unit::TestCase | ||
39 | 39 | ||
40 | should 'display invisible block for editing' do | 40 | should 'display invisible block for editing' do |
41 | p = create_user_with_blocks | 41 | p = create_user_with_blocks |
42 | + request = mock() | ||
43 | + request.expects(:path).returns(nil) | ||
44 | + | ||
42 | 45 | ||
43 | b = p.blocks.select{|bk| !bk.kind_of?(MainBlock) }[0] | 46 | b = p.blocks.select{|bk| !bk.kind_of?(MainBlock) }[0] |
44 | b.display = 'never'; b.save! | 47 | b.display = 'never'; b.save! |
45 | box = b.box | 48 | box = b.box |
46 | box.expects(:blocks).returns([b]) | 49 | box.expects(:blocks).returns([b]) |
47 | expects(:display_block).with(b, '') | 50 | expects(:display_block).with(b, '') |
51 | + expects(:request).returns(request) | ||
48 | stubs(:block_target).returns('') | 52 | stubs(:block_target).returns('') |
49 | with_box_decorator self do | 53 | with_box_decorator self do |
50 | display_box_content(box, '') | 54 | display_box_content(box, '') |
@@ -53,12 +57,15 @@ class BoxesHelperTest < Test::Unit::TestCase | @@ -53,12 +57,15 @@ class BoxesHelperTest < Test::Unit::TestCase | ||
53 | 57 | ||
54 | should 'not display invisible block' do | 58 | should 'not display invisible block' do |
55 | p = create_user_with_blocks | 59 | p = create_user_with_blocks |
60 | + request = mock() | ||
61 | + request.expects(:path).returns(nil) | ||
56 | 62 | ||
57 | b = p.blocks.select{|bk| !bk.kind_of?(MainBlock) }[0] | 63 | b = p.blocks.select{|bk| !bk.kind_of?(MainBlock) }[0] |
58 | b.display = 'never'; b.save! | 64 | b.display = 'never'; b.save! |
59 | box = b.box | 65 | box = b.box |
60 | box.expects(:blocks).returns([b]) | 66 | box.expects(:blocks).returns([b]) |
61 | expects(:display_block).with(b, '').never | 67 | expects(:display_block).with(b, '').never |
68 | + expects(:request).returns(request) | ||
62 | stubs(:block_target).returns('') | 69 | stubs(:block_target).returns('') |
63 | display_box_content(box, '') | 70 | display_box_content(box, '') |
64 | end | 71 | end |
@@ -94,4 +101,17 @@ class BoxesHelperTest < Test::Unit::TestCase | @@ -94,4 +101,17 @@ class BoxesHelperTest < Test::Unit::TestCase | ||
94 | assert !block_css_classes(Block.new(:display => 'always')).split.any? { |item| item == 'invisible-block'} | 101 | assert !block_css_classes(Block.new(:display => 'always')).split.any? { |item| item == 'invisible-block'} |
95 | assert block_css_classes(Block.new(:display => 'never')).split.any? { |item| item == 'invisible-block'} | 102 | assert block_css_classes(Block.new(:display => 'never')).split.any? { |item| item == 'invisible-block'} |
96 | end | 103 | end |
104 | + | ||
105 | + should 'fill context with the article and request_path' do | ||
106 | + request = mock() | ||
107 | + box = mock() | ||
108 | + | ||
109 | + box.expects(:blocks).returns([]) | ||
110 | + request.expects(:path).returns('/') | ||
111 | + expects(:request).returns(request) | ||
112 | + box_decorator.expects(:select_blocks).with([], {:article => nil, :request_path => '/'}).returns([]) | ||
113 | + | ||
114 | + display_box_content(box, '') | ||
115 | + end | ||
116 | + | ||
97 | end | 117 | end |