Commit 88b02d90b555e1cf3ca26355af6a592881e27b65

Authored by Victor Costa
1 parent 040b05e2

Fix cloning blocks at environment_design

(ActionItem3046)
app/controllers/box_organizer_controller.rb
@@ -99,6 +99,12 @@ class BoxOrganizerController < ApplicationController @@ -99,6 +99,12 @@ class BoxOrganizerController < ApplicationController
99 end 99 end
100 end 100 end
101 101
  102 + def clone_block
  103 + block = Block.find(params[:id])
  104 + block.duplicate
  105 + redirect_to :action => 'index'
  106 + end
  107 +
102 protected :boxes_editor? 108 protected :boxes_editor?
103 109
104 end 110 end
app/controllers/my_profile/profile_design_controller.rb
@@ -55,10 +55,4 @@ class ProfileDesignController < BoxOrganizerController @@ -55,10 +55,4 @@ class ProfileDesignController < BoxOrganizerController
55 blocks 55 blocks
56 end 56 end
57 57
58 - def clone  
59 - block = Block.find(params[:id])  
60 - block.duplicate  
61 - redirect_to :action => 'index'  
62 - end  
63 -  
64 end 58 end
app/helpers/boxes_helper.rb
@@ -212,7 +212,7 @@ module BoxesHelper @@ -212,7 +212,7 @@ module BoxesHelper
212 212
213 if !block.main? 213 if !block.main?
214 buttons << icon_button(:delete, _('Remove block'), { :action => 'remove', :id => block.id }, { :method => 'post', :confirm => _('Are you sure you want to remove this block?')}) 214 buttons << icon_button(:delete, _('Remove block'), { :action => 'remove', :id => block.id }, { :method => 'post', :confirm => _('Are you sure you want to remove this block?')})
215 - buttons << icon_button(:clone, _('Clone'), { :action => 'clone', :id => block.id }, { :method => 'post' }) 215 + buttons << icon_button(:clone, _('Clone'), { :action => 'clone_block', :id => block.id }, { :method => 'post' })
216 end 216 end
217 217
218 if block.respond_to?(:help) 218 if block.respond_to?(:help)
test/functional/environment_design_controller_test.rb
@@ -370,4 +370,13 @@ class EnvironmentDesignControllerTest &lt; ActionController::TestCase @@ -370,4 +370,13 @@ class EnvironmentDesignControllerTest &lt; ActionController::TestCase
370 assert @controller.instance_variable_get('@side_block_types').include?(CustomBlock8) 370 assert @controller.instance_variable_get('@side_block_types').include?(CustomBlock8)
371 end 371 end
372 372
  373 + should 'clone a block' do
  374 + login_as(create_admin_user(Environment.default))
  375 + block = TagsBlock.create!
  376 + assert_difference TagsBlock, :count, 1 do
  377 + post :clone_block, :id => block.id
  378 + assert_response :redirect
  379 + end
  380 + end
  381 +
373 end 382 end
test/functional/profile_design_controller_test.rb
@@ -739,7 +739,7 @@ class ProfileDesignControllerTest &lt; ActionController::TestCase @@ -739,7 +739,7 @@ class ProfileDesignControllerTest &lt; ActionController::TestCase
739 should 'clone a block' do 739 should 'clone a block' do
740 block = ProfileImageBlock.create!(:box => profile.boxes.first) 740 block = ProfileImageBlock.create!(:box => profile.boxes.first)
741 assert_difference ProfileImageBlock, :count, 1 do 741 assert_difference ProfileImageBlock, :count, 1 do
742 - post :clone, :id => block.id, :profile => profile.identifier 742 + post :clone_block, :id => block.id, :profile => profile.identifier
743 assert_response :redirect 743 assert_response :redirect
744 end 744 end
745 end 745 end