Mercurial > hg > soundsoftware-site
diff test/functional/.svn/text-base/wiki_controller_test.rb.svn-base @ 119:8661b858af72
* Update to Redmine trunk rev 4705
author | Chris Cannam |
---|---|
date | Thu, 13 Jan 2011 14:12:06 +0000 |
parents | 94944d00e43c |
children | cbce1fd3b1b7 |
line wrap: on
line diff
--- a/test/functional/.svn/text-base/wiki_controller_test.rb.svn-base Fri Nov 19 14:05:24 2010 +0000 +++ b/test/functional/.svn/text-base/wiki_controller_test.rb.svn-base Thu Jan 13 14:12:06 2011 +0000 @@ -15,7 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require File.dirname(__FILE__) + '/../test_helper' +require File.expand_path('../../test_helper', __FILE__) require 'wiki_controller' # Re-raise errors caught by the controller. @@ -108,6 +108,52 @@ 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