Fixed that adding a blank/invalid block to my page renders a blank page (#12838).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11225 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
8b23d41cf9
commit
6e6ce7c085
|
@ -147,15 +147,16 @@ class MyController < ApplicationController
|
||||||
# params[:block] : id of the block to add
|
# params[:block] : id of the block to add
|
||||||
def add_block
|
def add_block
|
||||||
block = params[:block].to_s.underscore
|
block = params[:block].to_s.underscore
|
||||||
(render :nothing => true; return) unless block && (BLOCKS.keys.include? block)
|
if block.present? && BLOCKS.key?(block)
|
||||||
@user = User.current
|
@user = User.current
|
||||||
layout = @user.pref[:my_page_layout] || {}
|
layout = @user.pref[:my_page_layout] || {}
|
||||||
# remove if already present in a group
|
# remove if already present in a group
|
||||||
%w(top left right).each {|f| (layout[f] ||= []).delete block }
|
%w(top left right).each {|f| (layout[f] ||= []).delete block }
|
||||||
# add it on top
|
# add it on top
|
||||||
layout['top'].unshift block
|
layout['top'].unshift block
|
||||||
@user.pref[:my_page_layout] = layout
|
@user.pref[:my_page_layout] = layout
|
||||||
@user.pref.save
|
@user.pref.save
|
||||||
|
end
|
||||||
redirect_to my_page_layout_path
|
redirect_to my_page_layout_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -191,6 +191,11 @@ class MyControllerTest < ActionController::TestCase
|
||||||
assert User.find(2).pref[:my_page_layout]['top'].include?('issuesreportedbyme')
|
assert User.find(2).pref[:my_page_layout]['top'].include?('issuesreportedbyme')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_add_invalid_block_should_redirect
|
||||||
|
post :add_block, :block => 'invalid'
|
||||||
|
assert_redirected_to '/my/page_layout'
|
||||||
|
end
|
||||||
|
|
||||||
def test_remove_block
|
def test_remove_block
|
||||||
post :remove_block, :block => 'issuesassignedtome'
|
post :remove_block, :block => 'issuesassignedtome'
|
||||||
assert_redirected_to '/my/page_layout'
|
assert_redirected_to '/my/page_layout'
|
||||||
|
|
Loading…
Reference in New Issue