@@ -100,9 +100,6 class WikiController < ApplicationController | |||
|
100 | 100 | |
|
101 | 101 | # To prevent StaleObjectError exception when reverting to a previous version |
|
102 | 102 | @content.version = @page.content.version |
|
103 | rescue ActiveRecord::StaleObjectError | |
|
104 | # Optimistic locking exception | |
|
105 | flash[:error] = l(:notice_locking_conflict) | |
|
106 | 103 | end |
|
107 | 104 | |
|
108 | 105 | verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } |
@@ -138,7 +135,8 class WikiController < ApplicationController | |||
|
138 | 135 | |
|
139 | 136 | rescue ActiveRecord::StaleObjectError |
|
140 | 137 | # Optimistic locking exception |
|
141 | flash[:error] = l(:notice_locking_conflict) | |
|
138 | flash.now[:error] = l(:notice_locking_conflict) | |
|
139 | render :action => 'edit' | |
|
142 | 140 | end |
|
143 | 141 | |
|
144 | 142 | # 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