ref: master
plugins/container_block/test/functional/container_block_plugin_controller_test.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
require 'test_helper' class ContainerBlockPluginControllerTest < ActionController::TestCase include ContainerBlockPluginController def setup Environment.delete_all @environment = Environment.new(:name => 'testenv', :is_default => true) @environment.enabled_plugins = ['ContainerBlockPlugin::ContainerBlock'] @environment.save! user = create_user('testinguser') @environment.add_admin(user.person) login_as(user.login) @block = ContainerBlockPlugin::ContainerBlock.create!(:box_id => @environment.boxes.first.id) @child1 = Block.create!(:box_id => @block.container_box.id) @child2 = Block.create!(:box_id => @block.container_box.id) @environment = Environment.find(@environment.id) stubs(:boxes_holder).returns(@environment) @params = {} end attr_reader :params should 'save widths of container block children' do @params = {:id => @block.id, :widths => "#{@child1.id},100|#{@child2.id},200"} expects(:render).with(:text => 'Block successfully saved.') saveWidths @block.reload assert_equal 100, @block.child_width(@child1.id) assert_equal 200, @block.child_width(@child2.id) end should 'do not change child width that is not passed in widths param' do @block.children_settings = {@child2.id => {:width => 200}} @block.save! @params = {:id => @block.id, :widths => "#{@child1.id},100"} expects(:render).with(:text => 'Block successfully saved.') saveWidths @block.reload assert_equal 100, @block.child_width(@child1.id) assert_equal 200, @block.child_width(@child2.id) end end |