Commit 8510ec43580812edc635f13f24ea2c6a48ead70b

Authored by Rodrigo Souto
1 parent 8d5373b9

container-block-plugin: add namespace to block class name

Whenever we are creating new models on plugins we should use the
plugin's namespace to avoid future name conflicts.
plugins/container_block/lib/container_block.rb
@@ -1,54 +0,0 @@ @@ -1,54 +0,0 @@
1 -class ContainerBlock < Block  
2 -  
3 - after_create :create_box  
4 - after_destroy :destroy_children  
5 -  
6 - settings_items :container_box_id, :type => Integer, :default => nil  
7 - settings_items :children_settings, :type => Hash, :default => {}  
8 -  
9 - def self.description  
10 - _('Container')  
11 - end  
12 -  
13 - def help  
14 - _('This block acts as a container for another blocks')  
15 - end  
16 -  
17 - def layout_template  
18 - nil  
19 - end  
20 -  
21 - def destroy_children  
22 - blocks.destroy_all  
23 - end  
24 -  
25 - def create_box  
26 - box = Box.create!(:owner => self)  
27 - settings[:container_box_id] = box.id  
28 - save!  
29 - end  
30 -  
31 - def container_box  
32 - Box.find(container_box_id)  
33 - end  
34 -  
35 - def block_classes=(classes)  
36 - classes.each { |c| block = c.constantize.create!(:box => container_box) } if classes  
37 - end  
38 -  
39 - def blocks  
40 - container_box.blocks  
41 - end  
42 -  
43 - def child_width(child_id)  
44 - children_settings[child_id][:width] if children_settings[child_id]  
45 - end  
46 -  
47 - def content(args={})  
48 - block = self  
49 - lambda do  
50 - render :file => 'blocks/container.rhtml', :locals => {:block => block}  
51 - end  
52 - end  
53 -  
54 -end  
plugins/container_block/lib/container_block_array.rb
@@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
1 -module ContainerBlockArray  
2 -  
3 - def blocks_with_container_block_plugin(reload = false)  
4 - blocks = blocks_without_container_block_plugin(reload)  
5 - blocks.each { |block| blocks.concat(block.blocks) if block.kind_of?(ContainerBlock) }  
6 - end  
7 -  
8 - def self.included(base)  
9 - base.class_eval do  
10 - alias_method_chain :blocks, :container_block_plugin  
11 - end  
12 - end  
13 -  
14 -end  
plugins/container_block/lib/container_block_plugin.rb
@@ -7,9 +7,9 @@ class ContainerBlockPlugin &lt; Noosfero::Plugin @@ -7,9 +7,9 @@ class ContainerBlockPlugin &lt; Noosfero::Plugin
7 def self.plugin_description 7 def self.plugin_description
8 _("A plugin that add a container block.") 8 _("A plugin that add a container block.")
9 end 9 end
10 - 10 +
11 def self.extra_blocks 11 def self.extra_blocks
12 - { ContainerBlock => {} } 12 + { ContainerBlockPlugin::ContainerBlock => {} }
13 end 13 end
14 14
15 def stylesheet? 15 def stylesheet?
plugins/container_block/lib/container_block_plugin/container_block.rb 0 → 100644
@@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
  1 +class ContainerBlockPlugin::ContainerBlock < Block
  2 +
  3 + after_create :create_box
  4 + after_destroy :destroy_children
  5 +
  6 + settings_items :container_box_id, :type => Integer, :default => nil
  7 + settings_items :children_settings, :type => Hash, :default => {}
  8 +
  9 + def self.description
  10 + _('Container')
  11 + end
  12 +
  13 + def help
  14 + _('This block acts as a container for another blocks')
  15 + end
  16 +
  17 + def layout_template
  18 + nil
  19 + end
  20 +
  21 + def destroy_children
  22 + blocks.destroy_all
  23 + end
  24 +
  25 + def create_box
  26 + box = Box.create!(:owner => self)
  27 + settings[:container_box_id] = box.id
  28 + save!
  29 + end
  30 +
  31 + def container_box
  32 + Box.find(container_box_id)
  33 + end
  34 +
  35 + def block_classes=(classes)
  36 + classes.each { |c| block = c.constantize.create!(:box => container_box) } if classes
  37 + end
  38 +
  39 + def blocks
  40 + container_box.blocks
  41 + end
  42 +
  43 + def child_width(child_id)
  44 + children_settings[child_id][:width] if children_settings[child_id]
  45 + end
  46 +
  47 + def content(args={})
  48 + block = self
  49 + lambda do
  50 + render :file => 'blocks/container.rhtml', :locals => {:block => block}
  51 + end
  52 + end
  53 +
  54 +end
plugins/container_block/lib/container_block_plugin/container_block_array.rb 0 → 100644
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +module ContainerBlockPlugin::ContainerBlockArray
  2 +
  3 + def blocks_with_container_block_plugin(reload = false)
  4 + blocks = blocks_without_container_block_plugin(reload)
  5 + blocks.each { |block| blocks.concat(block.blocks) if block.kind_of?(ContainerBlockPlugin::ContainerBlock) }
  6 + end
  7 +
  8 + def self.included(base)
  9 + base.class_eval do
  10 + alias_method_chain :blocks, :container_block_plugin
  11 + end
  12 + end
  13 +
  14 +end
plugins/container_block/lib/ext/block.rb
@@ -4,7 +4,7 @@ class Block @@ -4,7 +4,7 @@ class Block
4 4
5 def owner_with_container_block_plugin 5 def owner_with_container_block_plugin
6 owner = owner_without_container_block_plugin 6 owner = owner_without_container_block_plugin
7 - owner.kind_of?(ContainerBlock) ? owner.owner : owner 7 + owner.kind_of?(ContainerBlockPlugin::ContainerBlock) ? owner.owner : owner
8 end 8 end
9 9
10 alias_method_chain :owner, :container_block_plugin 10 alias_method_chain :owner, :container_block_plugin
plugins/container_block/lib/ext/environment.rb
@@ -2,6 +2,6 @@ require_dependency &#39;environment&#39; @@ -2,6 +2,6 @@ require_dependency &#39;environment&#39;
2 2
3 class Environment 3 class Environment
4 4
5 - include ContainerBlockArray 5 + include ContainerBlockPlugin::ContainerBlockArray
6 6
7 end 7 end
plugins/container_block/lib/ext/profile.rb
@@ -2,6 +2,6 @@ require_dependency &#39;profile&#39; @@ -2,6 +2,6 @@ require_dependency &#39;profile&#39;
2 2
3 class Profile 3 class Profile
4 4
5 - include ContainerBlockArray 5 + include ContainerBlockPlugin::ContainerBlockArray
6 6
7 end 7 end
plugins/container_block/public/style.css
1 -#content .boxes .container-block .container_block_child, .container-block .block-outer { 1 +#content .boxes .container-block-plugin/container-block .container_block_child, .container-block-plugin/container-block .block-outer {
2 display: inline-block; 2 display: inline-block;
3 vertical-align: top; 3 vertical-align: top;
4 margin-left: -2px; 4 margin-left: -2px;
5 margin-right: -2px; 5 margin-right: -2px;
6 } 6 }
7 7
8 -.container-block .block-target { 8 +.container-block-plugin/container-block .block-target {
9 clear: both; 9 clear: both;
10 } 10 }
11 11
12 -.container-block .block-target[id^='end-of-box-'] { 12 +.container-block-plugin/container-block .block-target[id^='end-of-box-'] {
13 display: none; 13 display: none;
14 } 14 }
15 15
16 -#content .boxes .container-block .block .icon-down, #content .boxes .container-block .block .icon-down-disabled { 16 +#content .boxes .container-block-plugin/container-block .block .icon-down, #content .boxes .container-block-plugin/container-block .block .icon-down-disabled {
17 background-image: url(/designs/icons/default/Tango/16x16/actions/go-next.png); 17 background-image: url(/designs/icons/default/Tango/16x16/actions/go-next.png);
18 } 18 }
19 19
20 -#content .boxes .container-block .block .icon-up, #content .boxes .container-block .block .icon-up-disabled { 20 +#content .boxes .container-block-plugin/container-block .block .icon-up, #content .boxes .container-block-plugin/container-block .block .icon-up-disabled {
21 background-image: url(/designs/icons/default/Tango/16x16/actions/go-previous.png); 21 background-image: url(/designs/icons/default/Tango/16x16/actions/go-previous.png);
22 } 22 }
23 23
24 -#content .boxes .container-block .block { 24 +#content .boxes .container-block-plugin/container-block .block {
25 outline-offset: -2px; 25 outline-offset: -2px;
26 } 26 }
27 27
28 -#content .boxes .container-block .block .ui-resizable-handle { 28 +#content .boxes .container-block-plugin/container-block .block .ui-resizable-handle {
29 width: 10px; 29 width: 10px;
30 height: 28px; 30 height: 28px;
31 z-index: 0; 31 z-index: 0;
32 } 32 }
33 33
34 -#content .boxes .container-block .block .ui-resizable-e { 34 +#content .boxes .container-block-plugin/container-block .block .ui-resizable-e {
35 right: -2px; 35 right: -2px;
36 background-image: url(/plugins/container_block/images/handle_e.png); 36 background-image: url(/plugins/container_block/images/handle_e.png);
37 } 37 }
38 38
39 -#content .boxes .container-block .block .ui-resizable-w { 39 +#content .boxes .container-block-plugin/container-block .block .ui-resizable-w {
40 left: -2px; 40 left: -2px;
41 background-image: url(/plugins/container_block/images/handle_w.png); 41 background-image: url(/plugins/container_block/images/handle_w.png);
42 } 42 }
43 43
44 -.container-block .button-bar .icon-resize { 44 +.container-block-plugin/container-block .button-bar .icon-resize {
45 background-image: url(/designs/icons/default/Tango/16x16/actions/view-fullscreen.png); 45 background-image: url(/designs/icons/default/Tango/16x16/actions/view-fullscreen.png);
46 } 46 }
plugins/container_block/test/functional/container_block_environment_design_controller_test.rb
@@ -13,14 +13,14 @@ class EnvironmentDesignControllerTest &lt; ActionController::TestCase @@ -13,14 +13,14 @@ class EnvironmentDesignControllerTest &lt; ActionController::TestCase
13 def setup 13 def setup
14 Environment.delete_all 14 Environment.delete_all
15 @environment = Environment.new(:name => 'testenv', :is_default => true) 15 @environment = Environment.new(:name => 'testenv', :is_default => true)
16 - @environment.enabled_plugins = ['ContainerBlock'] 16 + @environment.enabled_plugins = ['ContainerBlockPlugin::ContainerBlock']
17 @environment.save! 17 @environment.save!
18 18
19 user = create_user('testinguser') 19 user = create_user('testinguser')
20 @environment.add_admin(user.person) 20 @environment.add_admin(user.person)
21 login_as(user.login) 21 login_as(user.login)
22 22
23 - @block = ContainerBlock.create!(:box => @environment.boxes.first) 23 + @block = ContainerBlockPlugin::ContainerBlock.create!(:box => @environment.boxes.first)
24 end 24 end
25 25
26 should 'be able to edit ContainerBlock' do 26 should 'be able to edit ContainerBlock' do
plugins/container_block/test/functional/container_block_home_controller_test.rb
@@ -13,7 +13,7 @@ class HomeControllerTest &lt; ActionController::TestCase @@ -13,7 +13,7 @@ class HomeControllerTest &lt; ActionController::TestCase
13 def setup 13 def setup
14 Environment.delete_all 14 Environment.delete_all
15 @environment = Environment.new(:name => 'testenv', :is_default => true) 15 @environment = Environment.new(:name => 'testenv', :is_default => true)
16 - @environment.enabled_plugins = ['ContainerBlock'] 16 + @environment.enabled_plugins = ['ContainerBlockPlugin::ContainerBlock']
17 @environment.save! 17 @environment.save!
18 18
19 user = create_user('testinguser') 19 user = create_user('testinguser')
@@ -21,14 +21,14 @@ class HomeControllerTest &lt; ActionController::TestCase @@ -21,14 +21,14 @@ class HomeControllerTest &lt; ActionController::TestCase
21 login_as(user.login) 21 login_as(user.login)
22 22
23 box = Box.create!(:owner => @environment) 23 box = Box.create!(:owner => @environment)
24 - @block = ContainerBlock.create!(:box => box) 24 + @block = ContainerBlockPlugin::ContainerBlock.create!(:box => box)
25 25
26 @environment.boxes = [box] 26 @environment.boxes = [box]
27 end 27 end
28 28
29 should 'display ContainerBlock' do 29 should 'display ContainerBlock' do
30 get :index 30 get :index
31 - assert_tag :div, :attributes => { :class => 'block container-block' } 31 + assert_tag :div, :attributes => { :class => 'block container-block-plugin/container-block' }
32 end 32 end
33 33
34 should 'display container children' do 34 should 'display container children' do
plugins/container_block/test/functional/container_block_plugin_admin_controller_test.rb
@@ -5,14 +5,14 @@ class ContainerBlockPluginAdminControllerTest &lt; ActionController::TestCase @@ -5,14 +5,14 @@ class ContainerBlockPluginAdminControllerTest &lt; ActionController::TestCase
5 def setup 5 def setup
6 Environment.delete_all 6 Environment.delete_all
7 @environment = Environment.new(:name => 'testenv', :is_default => true) 7 @environment = Environment.new(:name => 'testenv', :is_default => true)
8 - @environment.enabled_plugins = ['ContainerBlock'] 8 + @environment.enabled_plugins = ['ContainerBlockPlugin::ContainerBlock']
9 @environment.save! 9 @environment.save!
10 10
11 user = create_user('testinguser') 11 user = create_user('testinguser')
12 @environment.add_admin(user.person) 12 @environment.add_admin(user.person)
13 login_as(user.login) 13 login_as(user.login)
14 14
15 - @block = ContainerBlock.create!(:box => @environment.boxes.first) 15 + @block = ContainerBlockPlugin::ContainerBlock.create!(:box => @environment.boxes.first)
16 @child1 = Block.create!(:box => @block.container_box) 16 @child1 = Block.create!(:box => @block.container_box)
17 @child2 = Block.create!(:box => @block.container_box) 17 @child2 = Block.create!(:box => @block.container_box)
18 end 18 end
plugins/container_block/test/functional/container_block_plugin_controller_test.rb
@@ -7,14 +7,14 @@ class ContainerBlockPluginControllerTest &lt; ActionController::TestCase @@ -7,14 +7,14 @@ class ContainerBlockPluginControllerTest &lt; ActionController::TestCase
7 def setup 7 def setup
8 Environment.delete_all 8 Environment.delete_all
9 @environment = Environment.new(:name => 'testenv', :is_default => true) 9 @environment = Environment.new(:name => 'testenv', :is_default => true)
10 - @environment.enabled_plugins = ['ContainerBlock'] 10 + @environment.enabled_plugins = ['ContainerBlockPlugin::ContainerBlock']
11 @environment.save! 11 @environment.save!
12 12
13 user = create_user('testinguser') 13 user = create_user('testinguser')
14 @environment.add_admin(user.person) 14 @environment.add_admin(user.person)
15 login_as(user.login) 15 login_as(user.login)
16 16
17 - @block = ContainerBlock.create!(:box => @environment.boxes.first) 17 + @block = ContainerBlockPlugin::ContainerBlock.create!(:box => @environment.boxes.first)
18 @child1 = Block.create!(:box => @block.container_box) 18 @child1 = Block.create!(:box => @block.container_box)
19 @child2 = Block.create!(:box => @block.container_box) 19 @child2 = Block.create!(:box => @block.container_box)
20 @environment = Environment.find(@environment.id) 20 @environment = Environment.find(@environment.id)
plugins/container_block/test/functional/container_block_plugin_myprofile_controller_test.rb
@@ -10,7 +10,7 @@ class ContainerBlockPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -10,7 +10,7 @@ class ContainerBlockPluginMyprofileControllerTest &lt; ActionController::TestCase
10 @profile.add_admin(user.person) 10 @profile.add_admin(user.person)
11 @box = Box.new(:owner => @profile) 11 @box = Box.new(:owner => @profile)
12 12
13 - @block = ContainerBlock.create!(:box => @box) 13 + @block = ContainerBlockPlugin::ContainerBlock.create!(:box => @box)
14 @child1 = Block.create!(:box => @block.container_box) 14 @child1 = Block.create!(:box => @block.container_box)
15 @child2 = Block.create!(:box => @block.container_box) 15 @child2 = Block.create!(:box => @block.container_box)
16 end 16 end
plugins/container_block/test/unit/block_test.rb
@@ -5,7 +5,7 @@ class BlockTest &lt; ActiveSupport::TestCase @@ -5,7 +5,7 @@ class BlockTest &lt; ActiveSupport::TestCase
5 def setup 5 def setup
6 @environment = fast_create(Environment) 6 @environment = fast_create(Environment)
7 @box = Box.create!(:owner => @environment) 7 @box = Box.create!(:owner => @environment)
8 - @container = ContainerBlock.create!(:box => @box) 8 + @container = ContainerBlockPlugin::ContainerBlock.create!(:box => @box)
9 end 9 end
10 10
11 should 'return environment box if block owner is not a ContainerBlock' do 11 should 'return environment box if block owner is not a ContainerBlock' do
plugins/container_block/test/unit/container_block_array_test.rb
@@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
1 -require File.dirname(__FILE__) + '/../test_helper'  
2 -  
3 -class ContainerBlockArrayTest < ActiveSupport::TestCase  
4 -  
5 - attr_reader :blocks  
6 -  
7 - include ContainerBlockArray  
8 -  
9 - def setup  
10 - @blocks = []  
11 -  
12 - @environment = fast_create(Environment)  
13 - @container_box = Box.new(:owner => @environment)  
14 - @container = ContainerBlock.new(:box => @container_box)  
15 - end  
16 -  
17 - should 'return blocks as usual' do  
18 - @blocks << Block.new  
19 - assert_equal @blocks, blocks_without_container_block_plugin  
20 - end  
21 -  
22 - should 'return blocks and container block children' do  
23 - @container.save!  
24 - @container_box.blocks << Block.new  
25 - @blocks.concat([Block.new, @container])  
26 - assert_equal @blocks + @container.blocks, blocks_without_container_block_plugin  
27 - end  
28 -  
29 -end  
plugins/container_block/test/unit/container_block_plugin/container_block_array_test.rb 0 → 100644
@@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +
  3 +class ContainerBlockPlugin::ContainerBlockArrayTest < ActiveSupport::TestCase
  4 +
  5 + attr_reader :blocks
  6 +
  7 + include ContainerBlockPlugin::ContainerBlockArray
  8 +
  9 + def setup
  10 + @blocks = []
  11 +
  12 + @environment = fast_create(Environment)
  13 + @container_box = Box.new(:owner => @environment)
  14 + @container = ContainerBlockPlugin::ContainerBlock.new(:box => @container_box)
  15 + end
  16 +
  17 + should 'return blocks as usual' do
  18 + @blocks << Block.new
  19 + assert_equal @blocks, blocks_without_container_block_plugin
  20 + end
  21 +
  22 + should 'return blocks and container block children' do
  23 + @container.save!
  24 + @container_box.blocks << Block.new
  25 + @blocks.concat([Block.new, @container])
  26 + assert_equal @blocks + @container.blocks, blocks_without_container_block_plugin
  27 + end
  28 +
  29 +end
plugins/container_block/test/unit/container_block_plugin/container_block_test.rb 0 → 100644
@@ -0,0 +1,85 @@ @@ -0,0 +1,85 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +
  3 +class ContainerBlockPlugin::ContainerBlockTest < ActiveSupport::TestCase
  4 +
  5 + def setup
  6 + @block = ContainerBlockPlugin::ContainerBlock.new
  7 + end
  8 +
  9 + should 'describe yourself' do
  10 + assert !ContainerBlockPlugin::ContainerBlock.description.blank?
  11 + end
  12 +
  13 + should 'has a help' do
  14 + assert !@block.help.blank?
  15 + end
  16 +
  17 + should 'create a box on save' do
  18 + @block.save!
  19 + assert @block.container_box_id
  20 + end
  21 +
  22 + should 'return created box' do
  23 + @block.save!
  24 + assert @block.container_box
  25 + end
  26 +
  27 + should 'create new blocks when receive block classes' do
  28 + Block.destroy_all
  29 + @block.save!
  30 + @block.block_classes = ['Block']
  31 + assert_equal 2, Block.count
  32 + assert_equal Block, Block.last.class
  33 + end
  34 +
  35 + should 'do not create blocks when nothing is passed as block classes' do
  36 + Block.destroy_all
  37 + @block.save!
  38 + @block.block_classes = []
  39 + assert_equal 1, Block.count
  40 + end
  41 +
  42 + should 'do not create blocks when nil is passed as block classes' do
  43 + Block.destroy_all
  44 + @block.save!
  45 + @block.block_classes = nil
  46 + assert_equal 1, Block.count
  47 + end
  48 +
  49 + should 'return a list of blocks associated with the container block' do
  50 + Block.destroy_all
  51 + @block.save!
  52 + @block.block_classes = ['Block', 'Block']
  53 + assert_equal [Block, Block], @block.blocks.map(&:class)
  54 + end
  55 +
  56 + should 'return child width' do
  57 + @block.children_settings = {1 => {:width => 10} }
  58 + @block.save!
  59 + assert_equal 10, @block.child_width(1)
  60 + end
  61 +
  62 + should 'return nil in width if child do not exists' do
  63 + @block.children_settings = {2 => {:width => 10} }
  64 + @block.save!
  65 + assert_equal nil, @block.child_width(1)
  66 + end
  67 +
  68 + should 'return nil at layout_templat' do
  69 + assert_equal nil, @block.layout_template
  70 + end
  71 +
  72 + should 'return children blocks that have container box as box' do
  73 + @block.save!
  74 + child = Block.create!(:box_id => @block.container_box.id)
  75 + assert_equal [child], @block.blocks
  76 + end
  77 +
  78 + should 'destroy chilrend when container is removed' do
  79 + @block.save!
  80 + child = Block.create!(:box_id => @block.container_box.id)
  81 + @block.destroy
  82 + assert !Block.exists?(child.id)
  83 + end
  84 +
  85 +end
plugins/container_block/test/unit/container_block_plugin_test.rb
@@ -15,7 +15,7 @@ class ContainerBlockPluginTest &lt; ActiveSupport::TestCase @@ -15,7 +15,7 @@ class ContainerBlockPluginTest &lt; ActiveSupport::TestCase
15 end 15 end
16 16
17 should 'add a block' do 17 should 'add a block' do
18 - assert_equal [ContainerBlock], ContainerBlockPlugin.extra_blocks.keys 18 + assert_equal [ContainerBlockPlugin::ContainerBlock], ContainerBlockPlugin.extra_blocks.keys
19 end 19 end
20 20
21 should 'has stylesheet' do 21 should 'has stylesheet' do
plugins/container_block/test/unit/container_block_test.rb
@@ -1,85 +0,0 @@ @@ -1,85 +0,0 @@
1 -require File.dirname(__FILE__) + '/../test_helper'  
2 -  
3 -class ContainerBlockTest < ActiveSupport::TestCase  
4 -  
5 - def setup  
6 - @block = ContainerBlock.new  
7 - end  
8 -  
9 - should 'describe yourself' do  
10 - assert !ContainerBlock.description.blank?  
11 - end  
12 -  
13 - should 'has a help' do  
14 - assert !@block.help.blank?  
15 - end  
16 -  
17 - should 'create a box on save' do  
18 - @block.save!  
19 - assert @block.container_box_id  
20 - end  
21 -  
22 - should 'return created box' do  
23 - @block.save!  
24 - assert @block.container_box  
25 - end  
26 -  
27 - should 'create new blocks when receive block classes' do  
28 - Block.destroy_all  
29 - @block.save!  
30 - @block.block_classes = ['Block']  
31 - assert_equal 2, Block.count  
32 - assert_equal Block, Block.last.class  
33 - end  
34 -  
35 - should 'do not create blocks when nothing is passed as block classes' do  
36 - Block.destroy_all  
37 - @block.save!  
38 - @block.block_classes = []  
39 - assert_equal 1, Block.count  
40 - end  
41 -  
42 - should 'do not create blocks when nil is passed as block classes' do  
43 - Block.destroy_all  
44 - @block.save!  
45 - @block.block_classes = nil  
46 - assert_equal 1, Block.count  
47 - end  
48 -  
49 - should 'return a list of blocks associated with the container block' do  
50 - Block.destroy_all  
51 - @block.save!  
52 - @block.block_classes = ['Block', 'Block']  
53 - assert_equal [Block, Block], @block.blocks.map(&:class)  
54 - end  
55 -  
56 - should 'return child width' do  
57 - @block.children_settings = {1 => {:width => 10} }  
58 - @block.save!  
59 - assert_equal 10, @block.child_width(1)  
60 - end  
61 -  
62 - should 'return nil in width if child do not exists' do  
63 - @block.children_settings = {2 => {:width => 10} }  
64 - @block.save!  
65 - assert_equal nil, @block.child_width(1)  
66 - end  
67 -  
68 - should 'return nil at layout_templat' do  
69 - assert_equal nil, @block.layout_template  
70 - end  
71 -  
72 - should 'return children blocks that have container box as box' do  
73 - @block.save!  
74 - child = Block.create!(:box_id => @block.container_box.id)  
75 - assert_equal [child], @block.blocks  
76 - end  
77 -  
78 - should 'destroy chilrend when container is removed' do  
79 - @block.save!  
80 - child = Block.create!(:box_id => @block.container_box.id)  
81 - @block.destroy  
82 - assert !Block.exists?(child.id)  
83 - end  
84 -  
85 -end  
plugins/container_block/test/unit/environment_test.rb
@@ -8,7 +8,7 @@ class EnvironmentTest &lt; ActiveSupport::TestCase @@ -8,7 +8,7 @@ class EnvironmentTest &lt; ActiveSupport::TestCase
8 @box = Box.create!(:owner => @environment) 8 @box = Box.create!(:owner => @environment)
9 @block = Block.create!(:box => @box) 9 @block = Block.create!(:box => @box)
10 10
11 - @container = ContainerBlock.create!(:box => @box) 11 + @container = ContainerBlockPlugin::ContainerBlock.create!(:box => @box)
12 end 12 end
13 13
14 should 'return blocks as usual' do 14 should 'return blocks as usual' do
plugins/container_block/test/unit/profile_test.rb
@@ -8,7 +8,7 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -8,7 +8,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
8 @box = Box.create!(:owner => @profile) 8 @box = Box.create!(:owner => @profile)
9 @block = Block.create!(:box => @box) 9 @block = Block.create!(:box => @box)
10 10
11 - @container = ContainerBlock.create!(:box => @box) 11 + @container = ContainerBlockPlugin::ContainerBlock.create!(:box => @box)
12 end 12 end
13 13
14 should 'return blocks as usual' do 14 should 'return blocks as usual' do