Fixed: Simultaneous wiki updates cause internal error (#7939).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5185 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
d1e5e1f504
commit
e0f37601f3
|
@ -100,9 +100,6 @@ class WikiController < ApplicationController
|
||||||
|
|
||||||
# To prevent StaleObjectError exception when reverting to a previous version
|
# To prevent StaleObjectError exception when reverting to a previous version
|
||||||
@content.version = @page.content.version
|
@content.version = @page.content.version
|
||||||
rescue ActiveRecord::StaleObjectError
|
|
||||||
# Optimistic locking exception
|
|
||||||
flash[:error] = l(:notice_locking_conflict)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
|
@ -138,7 +135,8 @@ class WikiController < ApplicationController
|
||||||
|
|
||||||
rescue ActiveRecord::StaleObjectError
|
rescue ActiveRecord::StaleObjectError
|
||||||
# Optimistic locking exception
|
# Optimistic locking exception
|
||||||
flash[:error] = l(:notice_locking_conflict)
|
flash.now[:error] = l(:notice_locking_conflict)
|
||||||
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
|
|
||||||
# rename a page
|
# rename a page
|
||||||
|
|
|
@ -155,6 +155,42 @@ class WikiControllerTest < ActionController::TestCase
|
||||||
assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'}
|
assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_update_stale_page_should_not_raise_an_error
|
||||||
|
@request.session[:user_id] = 2
|
||||||
|
c = Wiki.find(1).find_page('Another_page').content
|
||||||
|
c.text = 'Previous text'
|
||||||
|
c.save!
|
||||||
|
assert_equal 2, c.version
|
||||||
|
|
||||||
|
assert_no_difference 'WikiPage.count' do
|
||||||
|
assert_no_difference 'WikiContent.count' do
|
||||||
|
assert_no_difference 'WikiContent::Version.count' do
|
||||||
|
put :update, :project_id => 1,
|
||||||
|
:id => 'Another_page',
|
||||||
|
:content => {
|
||||||
|
:comments => 'My comments',
|
||||||
|
:text => 'Text should not be lost',
|
||||||
|
:version => 1
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'edit'
|
||||||
|
assert_tag :div,
|
||||||
|
:attributes => { :class => /error/ },
|
||||||
|
:content => /Data has been updated by another user/
|
||||||
|
assert_tag 'textarea',
|
||||||
|
:attributes => { :name => 'content[text]' },
|
||||||
|
:content => /Text should not be lost/
|
||||||
|
assert_tag 'input',
|
||||||
|
:attributes => { :name => 'content[comments]', :value => 'My comments' }
|
||||||
|
|
||||||
|
c.reload
|
||||||
|
assert_equal 'Previous text', c.text
|
||||||
|
assert_equal 2, c.version
|
||||||
|
end
|
||||||
|
|
||||||
def test_preview
|
def test_preview
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation',
|
xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation',
|
||||||
|
|
Loading…
Reference in New Issue