Commit b4e68a4a56dd72a02e254335defedbf1509fd39b
1 parent
8510ec43
Exists in
master
and in
29 other branches
container_block: clean test code
Although there are a lot of places on Noosfero where we do this test_helper ugly inclusion, they are just obsolete. Now we prefer to just include the test_helper and run the tests through rake tasks or including the path to the tests helper in the test run (something like: ruby -Itest ...).
Showing
15 changed files
with
22 additions
and
30 deletions
Show diff stats
plugins/container_block/lib/ext/block.rb
1 | require_dependency 'block' | 1 | require_dependency 'block' |
2 | 2 | ||
3 | class Block | 3 | class Block |
4 | - | ||
5 | def owner_with_container_block_plugin | 4 | def owner_with_container_block_plugin |
6 | owner = owner_without_container_block_plugin | 5 | owner = owner_without_container_block_plugin |
7 | owner.kind_of?(ContainerBlockPlugin::ContainerBlock) ? owner.owner : owner | 6 | owner.kind_of?(ContainerBlockPlugin::ContainerBlock) ? owner.owner : owner |
8 | end | 7 | end |
9 | 8 | ||
10 | alias_method_chain :owner, :container_block_plugin | 9 | alias_method_chain :owner, :container_block_plugin |
11 | - | ||
12 | end | 10 | end |
plugins/container_block/lib/ext/environment.rb
plugins/container_block/lib/ext/profile.rb
plugins/container_block/test/functional/container_block_environment_design_controller_test.rb
plugins/container_block/test/functional/container_block_home_controller_test.rb
plugins/container_block/test/functional/container_block_plugin_admin_controller_test.rb
plugins/container_block/test/functional/container_block_plugin_controller_test.rb
plugins/container_block/test/functional/container_block_plugin_myprofile_controller_test.rb
plugins/container_block/test/test_helper.rb
@@ -1 +0,0 @@ | @@ -1 +0,0 @@ | ||
1 | -require File.dirname(__FILE__) + '/../../../test/test_helper' |
plugins/container_block/test/unit/block_test.rb
plugins/container_block/test/unit/container_block_plugin/container_block_array_test.rb
plugins/container_block/test/unit/container_block_plugin/container_block_test.rb
1 | -require File.dirname(__FILE__) + '/../test_helper' | 1 | +require 'test_helper' |
2 | 2 | ||
3 | class ContainerBlockPlugin::ContainerBlockTest < ActiveSupport::TestCase | 3 | class ContainerBlockPlugin::ContainerBlockTest < ActiveSupport::TestCase |
4 | 4 | ||
@@ -25,29 +25,28 @@ class ContainerBlockPlugin::ContainerBlockTest < ActiveSupport::TestCase | @@ -25,29 +25,28 @@ class ContainerBlockPlugin::ContainerBlockTest < ActiveSupport::TestCase | ||
25 | end | 25 | end |
26 | 26 | ||
27 | should 'create new blocks when receive block classes' do | 27 | should 'create new blocks when receive block classes' do |
28 | - Block.destroy_all | ||
29 | @block.save! | 28 | @block.save! |
30 | - @block.block_classes = ['Block'] | ||
31 | - assert_equal 2, Block.count | 29 | + assert_difference Block, :count, 1 do |
30 | + @block.block_classes = ['Block'] | ||
31 | + end | ||
32 | assert_equal Block, Block.last.class | 32 | assert_equal Block, Block.last.class |
33 | end | 33 | end |
34 | 34 | ||
35 | should 'do not create blocks when nothing is passed as block classes' do | 35 | should 'do not create blocks when nothing is passed as block classes' do |
36 | - Block.destroy_all | ||
37 | @block.save! | 36 | @block.save! |
38 | - @block.block_classes = [] | ||
39 | - assert_equal 1, Block.count | 37 | + assert_no_difference Block, :count do |
38 | + @block.block_classes = [] | ||
39 | + end | ||
40 | end | 40 | end |
41 | 41 | ||
42 | should 'do not create blocks when nil is passed as block classes' do | 42 | should 'do not create blocks when nil is passed as block classes' do |
43 | - Block.destroy_all | ||
44 | @block.save! | 43 | @block.save! |
45 | - @block.block_classes = nil | ||
46 | - assert_equal 1, Block.count | 44 | + assert_no_difference Block, :count do |
45 | + @block.block_classes = nil | ||
46 | + end | ||
47 | end | 47 | end |
48 | 48 | ||
49 | should 'return a list of blocks associated with the container block' do | 49 | should 'return a list of blocks associated with the container block' do |
50 | - Block.destroy_all | ||
51 | @block.save! | 50 | @block.save! |
52 | @block.block_classes = ['Block', 'Block'] | 51 | @block.block_classes = ['Block', 'Block'] |
53 | assert_equal [Block, Block], @block.blocks.map(&:class) | 52 | assert_equal [Block, Block], @block.blocks.map(&:class) |
@@ -65,11 +64,11 @@ class ContainerBlockPlugin::ContainerBlockTest < ActiveSupport::TestCase | @@ -65,11 +64,11 @@ class ContainerBlockPlugin::ContainerBlockTest < ActiveSupport::TestCase | ||
65 | assert_equal nil, @block.child_width(1) | 64 | assert_equal nil, @block.child_width(1) |
66 | end | 65 | end |
67 | 66 | ||
68 | - should 'return nil at layout_templat' do | 67 | + should 'return nil at layout_template' do |
69 | assert_equal nil, @block.layout_template | 68 | assert_equal nil, @block.layout_template |
70 | end | 69 | end |
71 | 70 | ||
72 | - should 'return children blocks that have container box as box' do | 71 | + should 'return children blocks that have container_box as box' do |
73 | @block.save! | 72 | @block.save! |
74 | child = Block.create!(:box_id => @block.container_box.id) | 73 | child = Block.create!(:box_id => @block.container_box.id) |
75 | assert_equal [child], @block.blocks | 74 | assert_equal [child], @block.blocks |
plugins/container_block/test/unit/container_block_plugin_test.rb
plugins/container_block/test/unit/environment_test.rb
plugins/container_block/test/unit/profile_test.rb