Fixed: Missing template wiki/update.erb error introduced in r4272 (#6987).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4429 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2010-11-27 10:34:44 +00:00
parent d180c833b9
commit 4a6a551d07
3 changed files with 49 additions and 1 deletions

View File

@ -125,6 +125,8 @@ class WikiController < ApplicationController
render_attachment_warning_if_needed(@page)
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
redirect_to :action => 'show', :project_id => @project, :id => @page.title
else
render :action => 'edit'
end
rescue ActiveRecord::StaleObjectError

View File

@ -109,6 +109,52 @@ class WikiControllerTest < ActionController::TestCase
assert_equal 'testfile.txt', page.attachments.first.filename
end
def test_update_page
@request.session[:user_id] = 2
assert_no_difference 'WikiPage.count' do
assert_no_difference 'WikiContent.count' do
assert_difference 'WikiContent::Version.count' do
put :update, :project_id => 1,
:id => 'Another_page',
:content => {
:comments => "my comments",
:text => "edited",
:version => 1
}
end
end
end
assert_redirected_to '/projects/ecookbook/wiki/Another_page'
page = Wiki.find(1).pages.find_by_title('Another_page')
assert_equal "edited", page.content.text
assert_equal 2, page.content.version
assert_equal "my comments", page.content.comments
end
def test_update_page_with_failure
@request.session[:user_id] = 2
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 => 'a' * 300, # failure here, comment is too long
:text => 'edited',
:version => 1
}
end
end
end
assert_response :success
assert_template 'edit'
assert_error_tag :descendant => {:content => /Comment is too long/}
assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => 'edited'
assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'}
end
def test_preview
@request.session[:user_id] = 2
xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation',

View File

@ -115,7 +115,7 @@ class ActiveSupport::TestCase
end
def assert_error_tag(options={})
assert_tag({:tag => 'p', :attributes => { :id => 'errorExplanation' }}.merge(options))
assert_tag({:attributes => { :id => 'errorExplanation' }}.merge(options))
end
# Shoulda macros