Don't reload the page when adding/removing a block.

git-svn-id: http://svn.redmine.org/redmine/trunk@16394 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2017-03-13 20:02:34 +00:00
parent 327a6e54da
commit 28e34e101c
6 changed files with 40 additions and 11 deletions

View File

@@ -227,7 +227,7 @@ class MyControllerTest < Redmine::ControllerTest
xhr :post, :update_page, :settings => {'timelog' => {'days' => '14'}}
assert_response :success
assert_include '$("#block-timelog").html(', response.body
assert_include '$("#block-timelog").replaceWith(', response.body
assert_include '14 days', response.body
assert_equal({:days => "14"}, user.reload.pref.my_page_settings('timelog'))
@@ -239,9 +239,15 @@ class MyControllerTest < Redmine::ControllerTest
assert User.find(2).pref[:my_page_layout]['top'].include?('issuesreportedbyme')
end
def test_add_invalid_block_should_redirect
def test_add_block_xhr
xhr :post, :add_block, :block => 'issuesreportedbyme'
assert_response :success
assert_include 'issuesreportedbyme', User.find(2).pref[:my_page_layout]['top']
end
def test_add_invalid_block_should_error
post :add_block, :block => 'invalid'
assert_redirected_to '/my/page'
assert_response 422
end
def test_remove_block
@@ -250,6 +256,13 @@ class MyControllerTest < Redmine::ControllerTest
assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome')
end
def test_remove_block_xhr
xhr :post, :remove_block, :block => 'issuesassignedtome'
assert_response :success
assert_include '$("#block-issuesassignedtome").remove();', response.body
assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome')
end
def test_order_blocks
xhr :post, :order_blocks, :group => 'left', 'blocks' => ['documents', 'calendar', 'latestnews']
assert_response :success