@@ -93,9 +93,6 class WikiController < ApplicationController | |||
|
93 | 93 | |
|
94 | 94 | # To prevent StaleObjectError exception when reverting to a previous version |
|
95 | 95 | @content.version = @page.content.version |
|
96 | rescue ActiveRecord::StaleObjectError | |
|
97 | # Optimistic locking exception | |
|
98 | flash[:error] = l(:notice_locking_conflict) | |
|
99 | 96 | end |
|
100 | 97 | |
|
101 | 98 | verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } |
@@ -131,7 +128,8 class WikiController < ApplicationController | |||
|
131 | 128 | |
|
132 | 129 | rescue ActiveRecord::StaleObjectError |
|
133 | 130 | # Optimistic locking exception |
|
134 | flash[:error] = l(:notice_locking_conflict) | |
|
131 | flash.now[:error] = l(:notice_locking_conflict) | |
|
132 | render :action => 'edit' | |
|
135 | 133 | end |
|
136 | 134 | |
|
137 | 135 | # rename a page |
@@ -155,6 +155,42 class WikiControllerTest < ActionController::TestCase | |||
|
155 | 155 | assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'} |
|
156 | 156 | end |
|
157 | 157 | |
|
158 | def test_update_stale_page_should_not_raise_an_error | |
|
159 | @request.session[:user_id] = 2 | |
|
160 | c = Wiki.find(1).find_page('Another_page').content | |
|
161 | c.text = 'Previous text' | |
|
162 | c.save! | |
|
163 | assert_equal 2, c.version | |
|
164 | ||
|
165 | assert_no_difference 'WikiPage.count' do | |
|
166 | assert_no_difference 'WikiContent.count' do | |
|
167 | assert_no_difference 'WikiContent::Version.count' do | |
|
168 | put :update, :project_id => 1, | |
|
169 | :id => 'Another_page', | |
|
170 | :content => { | |
|
171 | :comments => 'My comments', | |
|
172 | :text => 'Text should not be lost', | |
|
173 | :version => 1 | |
|
174 | } | |
|
175 | end | |
|
176 | end | |
|
177 | end | |
|
178 | assert_response :success | |
|
179 | assert_template 'edit' | |
|
180 | assert_tag :div, | |
|
181 | :attributes => { :class => /error/ }, | |
|
182 | :content => /Data has been updated by another user/ | |
|
183 | assert_tag 'textarea', | |
|
184 | :attributes => { :name => 'content[text]' }, | |
|
185 | :content => /Text should not be lost/ | |
|
186 | assert_tag 'input', | |
|
187 | :attributes => { :name => 'content[comments]', :value => 'My comments' } | |
|
188 | ||
|
189 | c.reload | |
|
190 | assert_equal 'Previous text', c.text | |
|
191 | assert_equal 2, c.version | |
|
192 | end | |
|
193 | ||
|
158 | 194 | def test_preview |
|
159 | 195 | @request.session[:user_id] = 2 |
|
160 | 196 | xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation', |
General Comments 0
You need to be logged in to leave comments.
Login now