comparison 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
comparison
equal deleted inserted replaced
39:150ceac17a8d 119:8661b858af72
13 # 13 #
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 require File.dirname(__FILE__) + '/../test_helper' 18 require File.expand_path('../../test_helper', __FILE__)
19 require 'wiki_controller' 19 require 'wiki_controller'
20 20
21 # Re-raise errors caught by the controller. 21 # Re-raise errors caught by the controller.
22 class WikiController; def rescue_action(e) raise e end; end 22 class WikiController; def rescue_action(e) raise e end; end
23 23
105 end 105 end
106 end 106 end
107 page = Project.find(1).wiki.find_page('New page') 107 page = Project.find(1).wiki.find_page('New page')
108 assert_equal 1, page.attachments.count 108 assert_equal 1, page.attachments.count
109 assert_equal 'testfile.txt', page.attachments.first.filename 109 assert_equal 'testfile.txt', page.attachments.first.filename
110 end
111
112 def test_update_page
113 @request.session[:user_id] = 2
114 assert_no_difference 'WikiPage.count' do
115 assert_no_difference 'WikiContent.count' do
116 assert_difference 'WikiContent::Version.count' do
117 put :update, :project_id => 1,
118 :id => 'Another_page',
119 :content => {
120 :comments => "my comments",
121 :text => "edited",
122 :version => 1
123 }
124 end
125 end
126 end
127 assert_redirected_to '/projects/ecookbook/wiki/Another_page'
128
129 page = Wiki.find(1).pages.find_by_title('Another_page')
130 assert_equal "edited", page.content.text
131 assert_equal 2, page.content.version
132 assert_equal "my comments", page.content.comments
133 end
134
135 def test_update_page_with_failure
136 @request.session[:user_id] = 2
137 assert_no_difference 'WikiPage.count' do
138 assert_no_difference 'WikiContent.count' do
139 assert_no_difference 'WikiContent::Version.count' do
140 put :update, :project_id => 1,
141 :id => 'Another_page',
142 :content => {
143 :comments => 'a' * 300, # failure here, comment is too long
144 :text => 'edited',
145 :version => 1
146 }
147 end
148 end
149 end
150 assert_response :success
151 assert_template 'edit'
152
153 assert_error_tag :descendant => {:content => /Comment is too long/}
154 assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => 'edited'
155 assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'}
110 end 156 end
111 157
112 def test_preview 158 def test_preview
113 @request.session[:user_id] = 2 159 @request.session[:user_id] = 2
114 xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation', 160 xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation',