diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-01-20 17:01:03 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-01-20 17:01:03 +0000 |
commit | 98eb2edd2550ca781a528e9d1f2372e034bb280e (patch) | |
tree | a60fd4d211cb5af730f13266a5b95289cf6f3ffb | |
parent | ed7318fb8d74e7f2b21a245a48514957019563fe (diff) | |
download | redmine-98eb2edd2550ca781a528e9d1f2372e034bb280e.tar.gz redmine-98eb2edd2550ca781a528e9d1f2372e034bb280e.zip |
Merged r11225 from trunk (#12838).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.2-stable@11232 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/my_controller.rb | 19 | ||||
-rw-r--r-- | test/functional/my_controller_test.rb | 5 |
2 files changed, 15 insertions, 9 deletions
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index b2c2a9dc7..7a18c503e 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -147,15 +147,16 @@ class MyController < ApplicationController # params[:block] : id of the block to add def add_block block = params[:block].to_s.underscore - (render :nothing => true; return) unless block && (BLOCKS.keys.include? block) - @user = User.current - layout = @user.pref[:my_page_layout] || {} - # remove if already present in a group - %w(top left right).each {|f| (layout[f] ||= []).delete block } - # add it on top - layout['top'].unshift block - @user.pref[:my_page_layout] = layout - @user.pref.save + if block.present? && BLOCKS.key?(block) + @user = User.current + layout = @user.pref[:my_page_layout] || {} + # remove if already present in a group + %w(top left right).each {|f| (layout[f] ||= []).delete block } + # add it on top + layout['top'].unshift block + @user.pref[:my_page_layout] = layout + @user.pref.save + end redirect_to :action => 'page_layout' end diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb index f5f5f06b1..dfc7d6f89 100644 --- a/test/functional/my_controller_test.rb +++ b/test/functional/my_controller_test.rb @@ -187,6 +187,11 @@ class MyControllerTest < ActionController::TestCase assert User.find(2).pref[:my_page_layout]['top'].include?('issuesreportedbyme') end + def test_add_invalid_block_should_redirect + post :add_block, :block => 'invalid' + assert_redirected_to '/my/page_layout' + end + def test_remove_block post :remove_block, :block => 'issuesassignedtome' assert_redirected_to '/my/page_layout' |