From 4a6a551d074ce0680540a28f7c393733afa43422 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 27 Nov 2010 10:34:44 +0000 Subject: [PATCH] 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 --- app/controllers/wiki_controller.rb | 2 ++ test/functional/wiki_controller_test.rb | 46 +++++++++++++++++++++++++ test/test_helper.rb | 2 +- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index ae6f9d16..e7e38930 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -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 diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 74e9e11b..857975b8 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -108,6 +108,52 @@ class WikiControllerTest < ActionController::TestCase assert_equal 1, page.attachments.count 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 diff --git a/test/test_helper.rb b/test/test_helper.rb index ade46aa7..54681526 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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