Commit 8399cfcb0465fc0a94ae7f130e7bdc21cb951c39
Committed by
Antonio Terceiro
1 parent
2a4c443a
Exists in
master
and in
28 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 | 39 | |
| 40 | 40 | should 'display invisible block for editing' do |
| 41 | 41 | p = create_user_with_blocks |
| 42 | + request = mock() | |
| 43 | + request.expects(:path).returns(nil) | |
| 44 | + | |
| 42 | 45 | |
| 43 | 46 | b = p.blocks.select{|bk| !bk.kind_of?(MainBlock) }[0] |
| 44 | 47 | b.display = 'never'; b.save! |
| 45 | 48 | box = b.box |
| 46 | 49 | box.expects(:blocks).returns([b]) |
| 47 | 50 | expects(:display_block).with(b, '') |
| 51 | + expects(:request).returns(request) | |
| 48 | 52 | stubs(:block_target).returns('') |
| 49 | 53 | with_box_decorator self do |
| 50 | 54 | display_box_content(box, '') |
| ... | ... | @@ -53,12 +57,15 @@ class BoxesHelperTest < Test::Unit::TestCase |
| 53 | 57 | |
| 54 | 58 | should 'not display invisible block' do |
| 55 | 59 | p = create_user_with_blocks |
| 60 | + request = mock() | |
| 61 | + request.expects(:path).returns(nil) | |
| 56 | 62 | |
| 57 | 63 | b = p.blocks.select{|bk| !bk.kind_of?(MainBlock) }[0] |
| 58 | 64 | b.display = 'never'; b.save! |
| 59 | 65 | box = b.box |
| 60 | 66 | box.expects(:blocks).returns([b]) |
| 61 | 67 | expects(:display_block).with(b, '').never |
| 68 | + expects(:request).returns(request) | |
| 62 | 69 | stubs(:block_target).returns('') |
| 63 | 70 | display_box_content(box, '') |
| 64 | 71 | end |
| ... | ... | @@ -94,4 +101,17 @@ class BoxesHelperTest < Test::Unit::TestCase |
| 94 | 101 | assert !block_css_classes(Block.new(:display => 'always')).split.any? { |item| item == 'invisible-block'} |
| 95 | 102 | assert block_css_classes(Block.new(:display => 'never')).split.any? { |item| item == 'invisible-block'} |
| 96 | 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 | 117 | end | ... | ... |