Commit b4e68a4a56dd72a02e254335defedbf1509fd39b

Authored by Rodrigo Souto
1 parent 8510ec43

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 ...).
plugins/container_block/lib/ext/block.rb
1 1 require_dependency 'block'
2 2  
3 3 class Block
4   -
5 4 def owner_with_container_block_plugin
6 5 owner = owner_without_container_block_plugin
7 6 owner.kind_of?(ContainerBlockPlugin::ContainerBlock) ? owner.owner : owner
8 7 end
9 8  
10 9 alias_method_chain :owner, :container_block_plugin
11   -
12 10 end
... ...
plugins/container_block/lib/ext/environment.rb
1 1 require_dependency 'environment'
2 2  
3 3 class Environment
4   -
5 4 include ContainerBlockPlugin::ContainerBlockArray
6   -
7 5 end
... ...
plugins/container_block/lib/ext/profile.rb
1 1 require_dependency 'profile'
2 2  
3 3 class Profile
4   -
5 4 include ContainerBlockPlugin::ContainerBlockArray
6   -
7 5 end
... ...
plugins/container_block/test/functional/container_block_environment_design_controller_test.rb
1   -require File.dirname(__FILE__) + '/../test_helper'
  1 +require 'test_helper'
2 2  
3 3 # Re-raise errors caught by the controller.
4 4 class EnvironmentDesignController
... ...
plugins/container_block/test/functional/container_block_home_controller_test.rb
1   -require File.dirname(__FILE__) + '/../test_helper'
  1 +require 'test_helper'
2 2  
3 3 # Re-raise errors caught by the controller.
4 4 class HomeController
... ...
plugins/container_block/test/functional/container_block_plugin_admin_controller_test.rb
1   -require File.dirname(__FILE__) + '/../test_helper'
  1 +require 'test_helper'
2 2  
3 3 class ContainerBlockPluginAdminControllerTest < ActionController::TestCase
4 4  
... ...
plugins/container_block/test/functional/container_block_plugin_controller_test.rb
1   -require File.dirname(__FILE__) + '/../test_helper'
  1 +require 'test_helper'
2 2  
3 3 class ContainerBlockPluginControllerTest < ActionController::TestCase
4 4  
... ...
plugins/container_block/test/functional/container_block_plugin_myprofile_controller_test.rb
1   -require File.dirname(__FILE__) + '/../test_helper'
  1 +require 'test_helper'
2 2  
3 3 class ContainerBlockPluginMyprofileControllerTest < ActionController::TestCase
4 4  
... ...
plugins/container_block/test/test_helper.rb
... ... @@ -1 +0,0 @@
1   -require File.dirname(__FILE__) + '/../../../test/test_helper'
plugins/container_block/test/unit/block_test.rb
1   -require File.dirname(__FILE__) + '/../test_helper'
  1 +require 'test_helper'
2 2  
3 3 class BlockTest < ActiveSupport::TestCase
4 4  
... ...
plugins/container_block/test/unit/container_block_plugin/container_block_array_test.rb
1   -require File.dirname(__FILE__) + '/../test_helper'
  1 +require 'test_helper'
2 2  
3 3 class ContainerBlockPlugin::ContainerBlockArrayTest < ActiveSupport::TestCase
4 4  
... ...
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 3 class ContainerBlockPlugin::ContainerBlockTest < ActiveSupport::TestCase
4 4  
... ... @@ -25,29 +25,28 @@ class ContainerBlockPlugin::ContainerBlockTest &lt; ActiveSupport::TestCase
25 25 end
26 26  
27 27 should 'create new blocks when receive block classes' do
28   - Block.destroy_all
29 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 32 assert_equal Block, Block.last.class
33 33 end
34 34  
35 35 should 'do not create blocks when nothing is passed as block classes' do
36   - Block.destroy_all
37 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 40 end
41 41  
42 42 should 'do not create blocks when nil is passed as block classes' do
43   - Block.destroy_all
44 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 47 end
48 48  
49 49 should 'return a list of blocks associated with the container block' do
50   - Block.destroy_all
51 50 @block.save!
52 51 @block.block_classes = ['Block', 'Block']
53 52 assert_equal [Block, Block], @block.blocks.map(&:class)
... ... @@ -65,11 +64,11 @@ class ContainerBlockPlugin::ContainerBlockTest &lt; ActiveSupport::TestCase
65 64 assert_equal nil, @block.child_width(1)
66 65 end
67 66  
68   - should 'return nil at layout_templat' do
  67 + should 'return nil at layout_template' do
69 68 assert_equal nil, @block.layout_template
70 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 72 @block.save!
74 73 child = Block.create!(:box_id => @block.container_box.id)
75 74 assert_equal [child], @block.blocks
... ...
plugins/container_block/test/unit/container_block_plugin_test.rb
1   -require File.dirname(__FILE__) + '/../test_helper'
  1 +require 'test_helper'
2 2  
3 3 class ContainerBlockPluginTest < ActiveSupport::TestCase
4 4  
... ...
plugins/container_block/test/unit/environment_test.rb
1   -require File.dirname(__FILE__) + '/../test_helper'
  1 +require 'test_helper'
2 2  
3 3 class EnvironmentTest < ActiveSupport::TestCase
4 4  
... ...
plugins/container_block/test/unit/profile_test.rb
1   -require File.dirname(__FILE__) + '/../test_helper'
  1 +require 'test_helper'
2 2  
3 3 class ProfileTest < ActiveSupport::TestCase
4 4  
... ...