annotate test/functional/wiki_controller_test.rb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents cbb26bc654de
children 3e4c3460b6ca
rev   line source
Chris@441 1 # Redmine - project management software
Chris@1115 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@441 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@441 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@119 18 require File.expand_path('../../test_helper', __FILE__)
Chris@0 19 require 'wiki_controller'
Chris@0 20
Chris@0 21 # Re-raise errors caught by the controller.
Chris@0 22 class WikiController; def rescue_action(e) raise e end; end
Chris@0 23
Chris@0 24 class WikiControllerTest < ActionController::TestCase
Chris@909 25 fixtures :projects, :users, :roles, :members, :member_roles,
Chris@909 26 :enabled_modules, :wikis, :wiki_pages, :wiki_contents,
Chris@909 27 :wiki_content_versions, :attachments
Chris@441 28
Chris@0 29 def setup
Chris@0 30 @controller = WikiController.new
Chris@0 31 @request = ActionController::TestRequest.new
Chris@0 32 @response = ActionController::TestResponse.new
Chris@0 33 User.current = nil
Chris@0 34 end
Chris@441 35
Chris@0 36 def test_show_start_page
chris@37 37 get :show, :project_id => 'ecookbook'
Chris@0 38 assert_response :success
Chris@0 39 assert_template 'show'
Chris@0 40 assert_tag :tag => 'h1', :content => /CookBook documentation/
Chris@0 41
Chris@0 42 # child_pages macro
Chris@0 43 assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
Chris@0 44 :child => { :tag => 'li',
Chris@0 45 :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
Chris@0 46 :content => 'Page with an inline image' } }
Chris@0 47 end
Chris@909 48
Chris@909 49 def test_export_link
Chris@909 50 Role.anonymous.add_permission! :export_wiki_pages
Chris@909 51 get :show, :project_id => 'ecookbook'
Chris@909 52 assert_response :success
Chris@909 53 assert_tag 'a', :attributes => {:href => '/projects/ecookbook/wiki/CookBook_documentation.txt'}
Chris@909 54 end
Chris@441 55
Chris@0 56 def test_show_page_with_name
chris@37 57 get :show, :project_id => 1, :id => 'Another_page'
Chris@0 58 assert_response :success
Chris@0 59 assert_template 'show'
Chris@0 60 assert_tag :tag => 'h1', :content => /Another page/
Chris@0 61 # Included page with an inline image
Chris@0 62 assert_tag :tag => 'p', :content => /This is an inline image/
Chris@0 63 assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3',
Chris@0 64 :alt => 'This is a logo' }
Chris@0 65 end
Chris@441 66
Chris@1115 67 def test_show_old_version
Chris@1115 68 get :show, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2'
Chris@1115 69 assert_response :success
Chris@1115 70 assert_template 'show'
Chris@1115 71
Chris@1115 72 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/1', :text => /Previous/
Chris@1115 73 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/2/diff', :text => /diff/
Chris@1115 74 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/3', :text => /Next/
Chris@1115 75 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation', :text => /Current version/
Chris@1115 76 end
Chris@1115 77
Chris@1115 78 def test_show_old_version_without_permission_should_be_denied
Chris@1115 79 Role.anonymous.remove_permission! :view_wiki_edits
Chris@1115 80
Chris@1115 81 get :show, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2'
Chris@1115 82 assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fprojects%2Fecookbook%2Fwiki%2FCookBook_documentation%2F2'
Chris@1115 83 end
Chris@1115 84
Chris@1115 85 def test_show_first_version
Chris@1115 86 get :show, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '1'
Chris@1115 87 assert_response :success
Chris@1115 88 assert_template 'show'
Chris@1115 89
Chris@1115 90 assert_select 'a', :text => /Previous/, :count => 0
Chris@1115 91 assert_select 'a', :text => /diff/, :count => 0
Chris@1115 92 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/2', :text => /Next/
Chris@1115 93 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation', :text => /Current version/
Chris@1115 94 end
Chris@1115 95
Chris@441 96 def test_show_redirected_page
Chris@441 97 WikiRedirect.create!(:wiki_id => 1, :title => 'Old_title', :redirects_to => 'Another_page')
Chris@441 98
Chris@441 99 get :show, :project_id => 'ecookbook', :id => 'Old_title'
Chris@441 100 assert_redirected_to '/projects/ecookbook/wiki/Another_page'
Chris@441 101 end
Chris@441 102
Chris@0 103 def test_show_with_sidebar
Chris@0 104 page = Project.find(1).wiki.pages.new(:title => 'Sidebar')
Chris@0 105 page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
Chris@0 106 page.save!
Chris@441 107
chris@37 108 get :show, :project_id => 1, :id => 'Another_page'
Chris@0 109 assert_response :success
Chris@0 110 assert_tag :tag => 'div', :attributes => {:id => 'sidebar'},
Chris@0 111 :content => /Side bar content for test_show_with_sidebar/
Chris@0 112 end
Chris@909 113
Chris@909 114 def test_show_should_display_section_edit_links
Chris@909 115 @request.session[:user_id] = 2
Chris@909 116 get :show, :project_id => 1, :id => 'Page with sections'
Chris@909 117 assert_no_tag 'a', :attributes => {
Chris@909 118 :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=1'
Chris@909 119 }
Chris@909 120 assert_tag 'a', :attributes => {
Chris@909 121 :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=2'
Chris@909 122 }
Chris@909 123 assert_tag 'a', :attributes => {
Chris@909 124 :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=3'
Chris@909 125 }
Chris@909 126 end
Chris@909 127
Chris@909 128 def test_show_current_version_should_display_section_edit_links
Chris@909 129 @request.session[:user_id] = 2
Chris@909 130 get :show, :project_id => 1, :id => 'Page with sections', :version => 3
Chris@909 131
Chris@909 132 assert_tag 'a', :attributes => {
Chris@909 133 :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=2'
Chris@909 134 }
Chris@909 135 end
Chris@909 136
Chris@909 137 def test_show_old_version_should_not_display_section_edit_links
Chris@909 138 @request.session[:user_id] = 2
Chris@909 139 get :show, :project_id => 1, :id => 'Page with sections', :version => 2
Chris@909 140
Chris@909 141 assert_no_tag 'a', :attributes => {
Chris@909 142 :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=2'
Chris@909 143 }
Chris@909 144 end
Chris@441 145
Chris@1115 146 def test_show_unexistent_page_without_edit_right
Chris@1115 147 get :show, :project_id => 1, :id => 'Unexistent page'
Chris@1115 148 assert_response 404
Chris@1115 149 end
Chris@1115 150
Chris@0 151 def test_show_unexistent_page_with_edit_right
Chris@0 152 @request.session[:user_id] = 2
chris@37 153 get :show, :project_id => 1, :id => 'Unexistent page'
Chris@0 154 assert_response :success
Chris@0 155 assert_template 'edit'
Chris@0 156 end
Chris@441 157
Chris@1115 158 def test_show_unexistent_page_with_parent_should_preselect_parent
Chris@1115 159 @request.session[:user_id] = 2
Chris@1115 160 get :show, :project_id => 1, :id => 'Unexistent page', :parent => 'Another_page'
Chris@1115 161 assert_response :success
Chris@1115 162 assert_template 'edit'
Chris@1115 163 assert_tag 'select', :attributes => {:name => 'wiki_page[parent_id]'},
Chris@1115 164 :child => {:tag => 'option', :attributes => {:value => '2', :selected => 'selected'}}
Chris@1115 165 end
Chris@1115 166
Chris@1115 167 def test_show_should_not_show_history_without_permission
Chris@1115 168 Role.anonymous.remove_permission! :view_wiki_edits
Chris@1115 169 get :show, :project_id => 1, :id => 'Page with sections', :version => 2
Chris@1115 170
Chris@1115 171 assert_response 302
Chris@1115 172 end
Chris@1115 173
Chris@0 174 def test_create_page
Chris@0 175 @request.session[:user_id] = 2
Chris@1115 176 assert_difference 'WikiPage.count' do
Chris@1115 177 assert_difference 'WikiContent.count' do
Chris@1115 178 put :update, :project_id => 1,
Chris@1115 179 :id => 'New page',
Chris@1115 180 :content => {:comments => 'Created the page',
Chris@1115 181 :text => "h1. New page\n\nThis is a new page",
Chris@1115 182 :version => 0}
Chris@1115 183 end
Chris@1115 184 end
chris@37 185 assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'New_page'
Chris@0 186 page = Project.find(1).wiki.find_page('New page')
Chris@0 187 assert !page.new_record?
Chris@0 188 assert_not_nil page.content
Chris@1115 189 assert_nil page.parent
Chris@0 190 assert_equal 'Created the page', page.content.comments
Chris@0 191 end
Chris@441 192
Chris@0 193 def test_create_page_with_attachments
Chris@0 194 @request.session[:user_id] = 2
Chris@0 195 assert_difference 'WikiPage.count' do
Chris@0 196 assert_difference 'Attachment.count' do
chris@37 197 put :update, :project_id => 1,
chris@37 198 :id => 'New page',
Chris@0 199 :content => {:comments => 'Created the page',
Chris@0 200 :text => "h1. New page\n\nThis is a new page",
Chris@0 201 :version => 0},
Chris@0 202 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
Chris@0 203 end
Chris@0 204 end
Chris@0 205 page = Project.find(1).wiki.find_page('New page')
Chris@0 206 assert_equal 1, page.attachments.count
Chris@0 207 assert_equal 'testfile.txt', page.attachments.first.filename
Chris@0 208 end
Chris@119 209
Chris@1115 210 def test_create_page_with_parent
Chris@1115 211 @request.session[:user_id] = 2
Chris@1115 212 assert_difference 'WikiPage.count' do
Chris@1115 213 put :update, :project_id => 1, :id => 'New page',
Chris@1115 214 :content => {:text => "h1. New page\n\nThis is a new page", :version => 0},
Chris@1115 215 :wiki_page => {:parent_id => 2}
Chris@1115 216 end
Chris@1115 217 page = Project.find(1).wiki.find_page('New page')
Chris@1115 218 assert_equal WikiPage.find(2), page.parent
Chris@1115 219 end
Chris@1115 220
Chris@909 221 def test_edit_page
Chris@909 222 @request.session[:user_id] = 2
Chris@909 223 get :edit, :project_id => 'ecookbook', :id => 'Another_page'
Chris@909 224
Chris@909 225 assert_response :success
Chris@909 226 assert_template 'edit'
Chris@909 227
Chris@909 228 assert_tag 'textarea',
Chris@909 229 :attributes => { :name => 'content[text]' },
Chris@1115 230 :content => "\n"+WikiPage.find_by_title('Another_page').content.text
Chris@909 231 end
Chris@909 232
Chris@909 233 def test_edit_section
Chris@909 234 @request.session[:user_id] = 2
Chris@909 235 get :edit, :project_id => 'ecookbook', :id => 'Page_with_sections', :section => 2
Chris@909 236
Chris@909 237 assert_response :success
Chris@909 238 assert_template 'edit'
Chris@909 239
Chris@909 240 page = WikiPage.find_by_title('Page_with_sections')
Chris@909 241 section, hash = Redmine::WikiFormatting::Textile::Formatter.new(page.content.text).get_section(2)
Chris@909 242
Chris@909 243 assert_tag 'textarea',
Chris@909 244 :attributes => { :name => 'content[text]' },
Chris@1115 245 :content => "\n"+section
Chris@909 246 assert_tag 'input',
Chris@909 247 :attributes => { :name => 'section', :type => 'hidden', :value => '2' }
Chris@909 248 assert_tag 'input',
Chris@909 249 :attributes => { :name => 'section_hash', :type => 'hidden', :value => hash }
Chris@909 250 end
Chris@909 251
Chris@909 252 def test_edit_invalid_section_should_respond_with_404
Chris@909 253 @request.session[:user_id] = 2
Chris@909 254 get :edit, :project_id => 'ecookbook', :id => 'Page_with_sections', :section => 10
Chris@909 255
Chris@909 256 assert_response 404
Chris@909 257 end
Chris@909 258
Chris@119 259 def test_update_page
Chris@119 260 @request.session[:user_id] = 2
Chris@119 261 assert_no_difference 'WikiPage.count' do
Chris@119 262 assert_no_difference 'WikiContent.count' do
Chris@119 263 assert_difference 'WikiContent::Version.count' do
Chris@119 264 put :update, :project_id => 1,
Chris@119 265 :id => 'Another_page',
Chris@119 266 :content => {
Chris@119 267 :comments => "my comments",
Chris@119 268 :text => "edited",
Chris@119 269 :version => 1
Chris@119 270 }
Chris@119 271 end
Chris@119 272 end
Chris@119 273 end
Chris@119 274 assert_redirected_to '/projects/ecookbook/wiki/Another_page'
Chris@441 275
Chris@119 276 page = Wiki.find(1).pages.find_by_title('Another_page')
Chris@119 277 assert_equal "edited", page.content.text
Chris@119 278 assert_equal 2, page.content.version
Chris@119 279 assert_equal "my comments", page.content.comments
Chris@119 280 end
Chris@119 281
Chris@1115 282 def test_update_page_with_parent
Chris@1115 283 @request.session[:user_id] = 2
Chris@1115 284 assert_no_difference 'WikiPage.count' do
Chris@1115 285 assert_no_difference 'WikiContent.count' do
Chris@1115 286 assert_difference 'WikiContent::Version.count' do
Chris@1115 287 put :update, :project_id => 1,
Chris@1115 288 :id => 'Another_page',
Chris@1115 289 :content => {
Chris@1115 290 :comments => "my comments",
Chris@1115 291 :text => "edited",
Chris@1115 292 :version => 1
Chris@1115 293 },
Chris@1115 294 :wiki_page => {:parent_id => '1'}
Chris@1115 295 end
Chris@1115 296 end
Chris@1115 297 end
Chris@1115 298 assert_redirected_to '/projects/ecookbook/wiki/Another_page'
Chris@1115 299
Chris@1115 300 page = Wiki.find(1).pages.find_by_title('Another_page')
Chris@1115 301 assert_equal "edited", page.content.text
Chris@1115 302 assert_equal 2, page.content.version
Chris@1115 303 assert_equal "my comments", page.content.comments
Chris@1115 304 assert_equal WikiPage.find(1), page.parent
Chris@1115 305 end
Chris@1115 306
Chris@119 307 def test_update_page_with_failure
Chris@119 308 @request.session[:user_id] = 2
Chris@119 309 assert_no_difference 'WikiPage.count' do
Chris@119 310 assert_no_difference 'WikiContent.count' do
Chris@119 311 assert_no_difference 'WikiContent::Version.count' do
Chris@119 312 put :update, :project_id => 1,
Chris@119 313 :id => 'Another_page',
Chris@119 314 :content => {
Chris@119 315 :comments => 'a' * 300, # failure here, comment is too long
Chris@119 316 :text => 'edited',
Chris@119 317 :version => 1
Chris@119 318 }
Chris@119 319 end
Chris@119 320 end
Chris@119 321 end
Chris@119 322 assert_response :success
Chris@119 323 assert_template 'edit'
Chris@441 324
Chris@119 325 assert_error_tag :descendant => {:content => /Comment is too long/}
Chris@1115 326 assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => "\nedited"
Chris@119 327 assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'}
Chris@119 328 end
Chris@441 329
Chris@1115 330 def test_update_page_with_parent_change_only_should_not_create_content_version
Chris@1115 331 @request.session[:user_id] = 2
Chris@1115 332 assert_no_difference 'WikiPage.count' do
Chris@1115 333 assert_no_difference 'WikiContent.count' do
Chris@1115 334 assert_no_difference 'WikiContent::Version.count' do
Chris@1115 335 put :update, :project_id => 1,
Chris@1115 336 :id => 'Another_page',
Chris@1115 337 :content => {
Chris@1115 338 :comments => '',
Chris@1115 339 :text => Wiki.find(1).find_page('Another_page').content.text,
Chris@1115 340 :version => 1
Chris@1115 341 },
Chris@1115 342 :wiki_page => {:parent_id => '1'}
Chris@1115 343 end
Chris@1115 344 end
Chris@1115 345 end
Chris@1115 346 page = Wiki.find(1).pages.find_by_title('Another_page')
Chris@1115 347 assert_equal 1, page.content.version
Chris@1115 348 assert_equal WikiPage.find(1), page.parent
Chris@1115 349 end
Chris@1115 350
Chris@1115 351 def test_update_page_with_attachments_only_should_not_create_content_version
Chris@1115 352 @request.session[:user_id] = 2
Chris@1115 353 assert_no_difference 'WikiPage.count' do
Chris@1115 354 assert_no_difference 'WikiContent.count' do
Chris@1115 355 assert_no_difference 'WikiContent::Version.count' do
Chris@1115 356 assert_difference 'Attachment.count' do
Chris@1115 357 put :update, :project_id => 1,
Chris@1115 358 :id => 'Another_page',
Chris@1115 359 :content => {
Chris@1115 360 :comments => '',
Chris@1115 361 :text => Wiki.find(1).find_page('Another_page').content.text,
Chris@1115 362 :version => 1
Chris@1115 363 },
Chris@1115 364 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
Chris@1115 365 end
Chris@1115 366 end
Chris@1115 367 end
Chris@1115 368 end
Chris@1115 369 page = Wiki.find(1).pages.find_by_title('Another_page')
Chris@1115 370 assert_equal 1, page.content.version
Chris@1115 371 end
Chris@1115 372
Chris@441 373 def test_update_stale_page_should_not_raise_an_error
Chris@441 374 @request.session[:user_id] = 2
Chris@441 375 c = Wiki.find(1).find_page('Another_page').content
Chris@441 376 c.text = 'Previous text'
Chris@441 377 c.save!
Chris@441 378 assert_equal 2, c.version
Chris@441 379
Chris@441 380 assert_no_difference 'WikiPage.count' do
Chris@441 381 assert_no_difference 'WikiContent.count' do
Chris@441 382 assert_no_difference 'WikiContent::Version.count' do
Chris@441 383 put :update, :project_id => 1,
Chris@441 384 :id => 'Another_page',
Chris@441 385 :content => {
Chris@441 386 :comments => 'My comments',
Chris@441 387 :text => 'Text should not be lost',
Chris@441 388 :version => 1
Chris@441 389 }
Chris@441 390 end
Chris@441 391 end
Chris@441 392 end
Chris@441 393 assert_response :success
Chris@441 394 assert_template 'edit'
Chris@441 395 assert_tag :div,
Chris@441 396 :attributes => { :class => /error/ },
Chris@441 397 :content => /Data has been updated by another user/
Chris@441 398 assert_tag 'textarea',
Chris@441 399 :attributes => { :name => 'content[text]' },
Chris@441 400 :content => /Text should not be lost/
Chris@441 401 assert_tag 'input',
Chris@441 402 :attributes => { :name => 'content[comments]', :value => 'My comments' }
Chris@441 403
Chris@441 404 c.reload
Chris@441 405 assert_equal 'Previous text', c.text
Chris@441 406 assert_equal 2, c.version
Chris@441 407 end
Chris@441 408
Chris@909 409 def test_update_section
Chris@909 410 @request.session[:user_id] = 2
Chris@909 411 page = WikiPage.find_by_title('Page_with_sections')
Chris@909 412 section, hash = Redmine::WikiFormatting::Textile::Formatter.new(page.content.text).get_section(2)
Chris@909 413 text = page.content.text
Chris@909 414
Chris@909 415 assert_no_difference 'WikiPage.count' do
Chris@909 416 assert_no_difference 'WikiContent.count' do
Chris@909 417 assert_difference 'WikiContent::Version.count' do
Chris@909 418 put :update, :project_id => 1, :id => 'Page_with_sections',
Chris@909 419 :content => {
Chris@909 420 :text => "New section content",
Chris@909 421 :version => 3
Chris@909 422 },
Chris@909 423 :section => 2,
Chris@909 424 :section_hash => hash
Chris@909 425 end
Chris@909 426 end
Chris@909 427 end
Chris@909 428 assert_redirected_to '/projects/ecookbook/wiki/Page_with_sections'
Chris@909 429 assert_equal Redmine::WikiFormatting::Textile::Formatter.new(text).update_section(2, "New section content"), page.reload.content.text
Chris@909 430 end
Chris@909 431
Chris@909 432 def test_update_section_should_allow_stale_page_update
Chris@909 433 @request.session[:user_id] = 2
Chris@909 434 page = WikiPage.find_by_title('Page_with_sections')
Chris@909 435 section, hash = Redmine::WikiFormatting::Textile::Formatter.new(page.content.text).get_section(2)
Chris@909 436 text = page.content.text
Chris@909 437
Chris@909 438 assert_no_difference 'WikiPage.count' do
Chris@909 439 assert_no_difference 'WikiContent.count' do
Chris@909 440 assert_difference 'WikiContent::Version.count' do
Chris@909 441 put :update, :project_id => 1, :id => 'Page_with_sections',
Chris@909 442 :content => {
Chris@909 443 :text => "New section content",
Chris@909 444 :version => 2 # Current version is 3
Chris@909 445 },
Chris@909 446 :section => 2,
Chris@909 447 :section_hash => hash
Chris@909 448 end
Chris@909 449 end
Chris@909 450 end
Chris@909 451 assert_redirected_to '/projects/ecookbook/wiki/Page_with_sections'
Chris@909 452 page.reload
Chris@909 453 assert_equal Redmine::WikiFormatting::Textile::Formatter.new(text).update_section(2, "New section content"), page.content.text
Chris@909 454 assert_equal 4, page.content.version
Chris@909 455 end
Chris@909 456
Chris@909 457 def test_update_section_should_not_allow_stale_section_update
Chris@909 458 @request.session[:user_id] = 2
Chris@909 459
Chris@909 460 assert_no_difference 'WikiPage.count' do
Chris@909 461 assert_no_difference 'WikiContent.count' do
Chris@909 462 assert_no_difference 'WikiContent::Version.count' do
Chris@909 463 put :update, :project_id => 1, :id => 'Page_with_sections',
Chris@909 464 :content => {
Chris@909 465 :comments => 'My comments',
Chris@909 466 :text => "Text should not be lost",
Chris@909 467 :version => 3
Chris@909 468 },
Chris@909 469 :section => 2,
Chris@909 470 :section_hash => Digest::MD5.hexdigest("wrong hash")
Chris@909 471 end
Chris@909 472 end
Chris@909 473 end
Chris@909 474 assert_response :success
Chris@909 475 assert_template 'edit'
Chris@909 476 assert_tag :div,
Chris@909 477 :attributes => { :class => /error/ },
Chris@909 478 :content => /Data has been updated by another user/
Chris@909 479 assert_tag 'textarea',
Chris@909 480 :attributes => { :name => 'content[text]' },
Chris@909 481 :content => /Text should not be lost/
Chris@909 482 assert_tag 'input',
Chris@909 483 :attributes => { :name => 'content[comments]', :value => 'My comments' }
Chris@909 484 end
Chris@909 485
Chris@0 486 def test_preview
Chris@0 487 @request.session[:user_id] = 2
chris@37 488 xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation',
Chris@0 489 :content => { :comments => '',
Chris@0 490 :text => 'this is a *previewed text*',
Chris@0 491 :version => 3 }
Chris@0 492 assert_response :success
Chris@0 493 assert_template 'common/_preview'
Chris@0 494 assert_tag :tag => 'strong', :content => /previewed text/
Chris@0 495 end
Chris@441 496
Chris@0 497 def test_preview_new_page
Chris@0 498 @request.session[:user_id] = 2
chris@37 499 xhr :post, :preview, :project_id => 1, :id => 'New page',
Chris@0 500 :content => { :text => 'h1. New page',
Chris@0 501 :comments => '',
Chris@0 502 :version => 0 }
Chris@0 503 assert_response :success
Chris@0 504 assert_template 'common/_preview'
Chris@0 505 assert_tag :tag => 'h1', :content => /New page/
Chris@0 506 end
Chris@441 507
Chris@0 508 def test_history
Chris@1115 509 @request.session[:user_id] = 2
Chris@1115 510 get :history, :project_id => 'ecookbook', :id => 'CookBook_documentation'
Chris@0 511 assert_response :success
Chris@0 512 assert_template 'history'
Chris@0 513 assert_not_nil assigns(:versions)
Chris@0 514 assert_equal 3, assigns(:versions).size
Chris@1115 515
Chris@0 516 assert_select "input[type=submit][name=commit]"
Chris@1115 517 assert_select 'td' do
Chris@1115 518 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/2', :text => '2'
Chris@1115 519 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/2/annotate', :text => 'Annotate'
Chris@1115 520 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/2', :text => 'Delete'
Chris@1115 521 end
Chris@0 522 end
Chris@0 523
Chris@0 524 def test_history_with_one_version
Chris@1115 525 @request.session[:user_id] = 2
Chris@1115 526 get :history, :project_id => 'ecookbook', :id => 'Another_page'
Chris@0 527 assert_response :success
Chris@0 528 assert_template 'history'
Chris@0 529 assert_not_nil assigns(:versions)
Chris@0 530 assert_equal 1, assigns(:versions).size
Chris@0 531 assert_select "input[type=submit][name=commit]", false
Chris@1115 532 assert_select 'td' do
Chris@1115 533 assert_select 'a[href=?]', '/projects/ecookbook/wiki/Another_page/1', :text => '1'
Chris@1115 534 assert_select 'a[href=?]', '/projects/ecookbook/wiki/Another_page/1/annotate', :text => 'Annotate'
Chris@1115 535 assert_select 'a[href=?]', '/projects/ecookbook/wiki/Another_page/1', :text => 'Delete', :count => 0
Chris@1115 536 end
Chris@0 537 end
Chris@441 538
Chris@0 539 def test_diff
Chris@1115 540 content = WikiPage.find(1).content
Chris@1115 541 assert_difference 'WikiContent::Version.count', 2 do
Chris@1115 542 content.text = "Line removed\nThis is a sample text for testing diffs"
Chris@1115 543 content.save!
Chris@1115 544 content.text = "This is a sample text for testing diffs\nLine added"
Chris@1115 545 content.save!
Chris@1115 546 end
Chris@1115 547
Chris@1115 548 get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => content.version, :version_from => (content.version - 1)
Chris@0 549 assert_response :success
Chris@0 550 assert_template 'diff'
Chris@1115 551 assert_select 'span.diff_out', :text => 'Line removed'
Chris@1115 552 assert_select 'span.diff_in', :text => 'Line added'
Chris@1115 553 end
Chris@1115 554
Chris@1115 555 def test_diff_with_invalid_version_should_respond_with_404
Chris@1115 556 get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => '99'
Chris@1115 557 assert_response 404
Chris@1115 558 end
Chris@1115 559
Chris@1115 560 def test_diff_with_invalid_version_from_should_respond_with_404
Chris@1115 561 get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => '99', :version_from => '98'
Chris@1115 562 assert_response 404
Chris@0 563 end
Chris@441 564
Chris@0 565 def test_annotate
chris@37 566 get :annotate, :project_id => 1, :id => 'CookBook_documentation', :version => 2
Chris@0 567 assert_response :success
Chris@0 568 assert_template 'annotate'
Chris@909 569
Chris@0 570 # Line 1
Chris@507 571 assert_tag :tag => 'tr', :child => {
Chris@507 572 :tag => 'th', :attributes => {:class => 'line-num'}, :content => '1', :sibling => {
Chris@507 573 :tag => 'td', :attributes => {:class => 'author'}, :content => /John Smith/, :sibling => {
Chris@507 574 :tag => 'td', :content => /h1\. CookBook documentation/
Chris@507 575 }
Chris@507 576 }
Chris@507 577 }
Chris@909 578
Chris@507 579 # Line 5
Chris@507 580 assert_tag :tag => 'tr', :child => {
Chris@507 581 :tag => 'th', :attributes => {:class => 'line-num'}, :content => '5', :sibling => {
Chris@507 582 :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/, :sibling => {
Chris@507 583 :tag => 'td', :content => /Some updated \[\[documentation\]\] here/
Chris@507 584 }
Chris@507 585 }
Chris@507 586 }
Chris@0 587 end
chris@37 588
Chris@1115 589 def test_annotate_with_invalid_version_should_respond_with_404
Chris@1115 590 get :annotate, :project_id => 1, :id => 'CookBook_documentation', :version => '99'
Chris@1115 591 assert_response 404
Chris@1115 592 end
Chris@1115 593
chris@37 594 def test_get_rename
chris@37 595 @request.session[:user_id] = 2
chris@37 596 get :rename, :project_id => 1, :id => 'Another_page'
chris@37 597 assert_response :success
chris@37 598 assert_template 'rename'
chris@37 599 assert_tag 'option',
chris@37 600 :attributes => {:value => ''},
chris@37 601 :content => '',
chris@37 602 :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
chris@37 603 assert_no_tag 'option',
chris@37 604 :attributes => {:selected => 'selected'},
chris@37 605 :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
chris@37 606 end
Chris@441 607
chris@37 608 def test_get_rename_child_page
chris@37 609 @request.session[:user_id] = 2
chris@37 610 get :rename, :project_id => 1, :id => 'Child_1'
chris@37 611 assert_response :success
chris@37 612 assert_template 'rename'
chris@37 613 assert_tag 'option',
chris@37 614 :attributes => {:value => ''},
chris@37 615 :content => '',
chris@37 616 :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
chris@37 617 assert_tag 'option',
chris@37 618 :attributes => {:value => '2', :selected => 'selected'},
chris@37 619 :content => /Another page/,
chris@37 620 :parent => {
chris@37 621 :tag => 'select',
chris@37 622 :attributes => {:name => 'wiki_page[parent_id]'}
chris@37 623 }
chris@37 624 end
Chris@441 625
Chris@0 626 def test_rename_with_redirect
Chris@0 627 @request.session[:user_id] = 2
chris@37 628 post :rename, :project_id => 1, :id => 'Another_page',
Chris@0 629 :wiki_page => { :title => 'Another renamed page',
Chris@0 630 :redirect_existing_links => 1 }
chris@37 631 assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page'
Chris@0 632 wiki = Project.find(1).wiki
Chris@0 633 # Check redirects
Chris@0 634 assert_not_nil wiki.find_page('Another page')
Chris@0 635 assert_nil wiki.find_page('Another page', :with_redirect => false)
Chris@0 636 end
Chris@0 637
Chris@0 638 def test_rename_without_redirect
Chris@0 639 @request.session[:user_id] = 2
chris@37 640 post :rename, :project_id => 1, :id => 'Another_page',
Chris@0 641 :wiki_page => { :title => 'Another renamed page',
Chris@0 642 :redirect_existing_links => "0" }
chris@37 643 assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page'
Chris@0 644 wiki = Project.find(1).wiki
Chris@0 645 # Check that there's no redirects
Chris@0 646 assert_nil wiki.find_page('Another page')
Chris@0 647 end
Chris@441 648
chris@37 649 def test_rename_with_parent_assignment
chris@37 650 @request.session[:user_id] = 2
chris@37 651 post :rename, :project_id => 1, :id => 'Another_page',
chris@37 652 :wiki_page => { :title => 'Another page', :redirect_existing_links => "0", :parent_id => '4' }
chris@37 653 assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page'
chris@37 654 assert_equal WikiPage.find(4), WikiPage.find_by_title('Another_page').parent
chris@37 655 end
chris@37 656
chris@37 657 def test_rename_with_parent_unassignment
chris@37 658 @request.session[:user_id] = 2
chris@37 659 post :rename, :project_id => 1, :id => 'Child_1',
chris@37 660 :wiki_page => { :title => 'Child 1', :redirect_existing_links => "0", :parent_id => '' }
chris@37 661 assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Child_1'
chris@37 662 assert_nil WikiPage.find_by_title('Child_1').parent
chris@37 663 end
Chris@441 664
Chris@1115 665 def test_destroy_a_page_without_children_should_not_ask_confirmation
Chris@0 666 @request.session[:user_id] = 2
Chris@1115 667 delete :destroy, :project_id => 1, :id => 'Child_2'
chris@37 668 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
Chris@0 669 end
Chris@441 670
Chris@1115 671 def test_destroy_parent_should_ask_confirmation
Chris@0 672 @request.session[:user_id] = 2
Chris@0 673 assert_no_difference('WikiPage.count') do
chris@37 674 delete :destroy, :project_id => 1, :id => 'Another_page'
Chris@0 675 end
Chris@0 676 assert_response :success
Chris@0 677 assert_template 'destroy'
Chris@1115 678 assert_select 'form' do
Chris@1115 679 assert_select 'input[name=todo][value=nullify]'
Chris@1115 680 assert_select 'input[name=todo][value=destroy]'
Chris@1115 681 assert_select 'input[name=todo][value=reassign]'
Chris@1115 682 end
Chris@0 683 end
Chris@441 684
Chris@1115 685 def test_destroy_parent_with_nullify_should_delete_parent_only
Chris@0 686 @request.session[:user_id] = 2
Chris@0 687 assert_difference('WikiPage.count', -1) do
chris@37 688 delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'nullify'
Chris@0 689 end
chris@37 690 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
Chris@0 691 assert_nil WikiPage.find_by_id(2)
Chris@0 692 end
Chris@441 693
Chris@1115 694 def test_destroy_parent_with_cascade_should_delete_descendants
Chris@0 695 @request.session[:user_id] = 2
Chris@1115 696 assert_difference('WikiPage.count', -4) do
chris@37 697 delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'destroy'
Chris@0 698 end
chris@37 699 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
Chris@0 700 assert_nil WikiPage.find_by_id(2)
Chris@0 701 assert_nil WikiPage.find_by_id(5)
Chris@0 702 end
Chris@441 703
Chris@0 704 def test_destroy_parent_with_reassign
Chris@0 705 @request.session[:user_id] = 2
Chris@0 706 assert_difference('WikiPage.count', -1) do
chris@37 707 delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'reassign', :reassign_to_id => 1
Chris@0 708 end
chris@37 709 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
Chris@0 710 assert_nil WikiPage.find_by_id(2)
Chris@0 711 assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent
Chris@0 712 end
Chris@441 713
Chris@1115 714 def test_destroy_version
Chris@1115 715 @request.session[:user_id] = 2
Chris@1115 716 assert_difference 'WikiContent::Version.count', -1 do
Chris@1115 717 assert_no_difference 'WikiContent.count' do
Chris@1115 718 assert_no_difference 'WikiPage.count' do
Chris@1115 719 delete :destroy_version, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => 2
Chris@1115 720 assert_redirected_to '/projects/ecookbook/wiki/CookBook_documentation/history'
Chris@1115 721 end
Chris@1115 722 end
Chris@1115 723 end
Chris@1115 724 end
Chris@1115 725
chris@37 726 def test_index
chris@37 727 get :index, :project_id => 'ecookbook'
Chris@0 728 assert_response :success
chris@37 729 assert_template 'index'
Chris@0 730 pages = assigns(:pages)
Chris@0 731 assert_not_nil pages
Chris@0 732 assert_equal Project.find(1).wiki.pages.size, pages.size
Chris@441 733 assert_equal pages.first.content.updated_on, pages.first.updated_on
Chris@441 734
Chris@0 735 assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
Chris@0 736 :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' },
Chris@0 737 :content => 'CookBook documentation' },
Chris@0 738 :child => { :tag => 'ul',
Chris@0 739 :child => { :tag => 'li',
Chris@0 740 :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
Chris@0 741 :content => 'Page with an inline image' } } } },
Chris@0 742 :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' },
Chris@0 743 :content => 'Another page' } }
Chris@0 744 end
chris@37 745
Chris@441 746 def test_index_should_include_atom_link
Chris@441 747 get :index, :project_id => 'ecookbook'
Chris@441 748 assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'}
Chris@441 749 end
Chris@441 750
Chris@1115 751 def test_export_to_html
Chris@1115 752 @request.session[:user_id] = 2
Chris@1115 753 get :export, :project_id => 'ecookbook'
Chris@441 754
Chris@1115 755 assert_response :success
Chris@1115 756 assert_not_nil assigns(:pages)
Chris@1115 757 assert assigns(:pages).any?
Chris@1115 758 assert_equal "text/html", @response.content_type
Chris@441 759
Chris@1115 760 assert_select "a[name=?]", "CookBook_documentation"
Chris@1115 761 assert_select "a[name=?]", "Another_page"
Chris@1115 762 assert_select "a[name=?]", "Page_with_an_inline_image"
chris@37 763 end
chris@37 764
Chris@1115 765 def test_export_to_pdf
Chris@1115 766 @request.session[:user_id] = 2
Chris@1115 767 get :export, :project_id => 'ecookbook', :format => 'pdf'
chris@37 768
Chris@1115 769 assert_response :success
Chris@1115 770 assert_not_nil assigns(:pages)
Chris@1115 771 assert assigns(:pages).any?
Chris@1115 772 assert_equal 'application/pdf', @response.content_type
Chris@1115 773 assert_equal 'attachment; filename="ecookbook.pdf"', @response.headers['Content-Disposition']
Chris@1115 774 assert @response.body.starts_with?('%PDF')
Chris@1115 775 end
Chris@441 776
Chris@1115 777 def test_export_without_permission_should_be_denied
Chris@1115 778 @request.session[:user_id] = 2
Chris@1115 779 Role.find_by_name('Manager').remove_permission! :export_wiki_pages
Chris@1115 780 get :export, :project_id => 'ecookbook'
Chris@1115 781
Chris@1115 782 assert_response 403
Chris@1115 783 end
Chris@1115 784
Chris@1115 785 def test_date_index
Chris@1115 786 get :date_index, :project_id => 'ecookbook'
Chris@1115 787
Chris@1115 788 assert_response :success
Chris@1115 789 assert_template 'date_index'
Chris@1115 790 assert_not_nil assigns(:pages)
Chris@1115 791 assert_not_nil assigns(:pages_by_date)
Chris@1115 792
Chris@1115 793 assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'}
chris@37 794 end
Chris@441 795
Chris@0 796 def test_not_found
chris@37 797 get :show, :project_id => 999
Chris@0 798 assert_response 404
Chris@0 799 end
Chris@441 800
Chris@0 801 def test_protect_page
Chris@0 802 page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
Chris@0 803 assert !page.protected?
Chris@0 804 @request.session[:user_id] = 2
chris@37 805 post :protect, :project_id => 1, :id => page.title, :protected => '1'
chris@37 806 assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page'
Chris@0 807 assert page.reload.protected?
Chris@0 808 end
Chris@441 809
Chris@0 810 def test_unprotect_page
Chris@0 811 page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation')
Chris@0 812 assert page.protected?
Chris@0 813 @request.session[:user_id] = 2
chris@37 814 post :protect, :project_id => 1, :id => page.title, :protected => '0'
chris@37 815 assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'CookBook_documentation'
Chris@0 816 assert !page.reload.protected?
Chris@0 817 end
Chris@441 818
Chris@0 819 def test_show_page_with_edit_link
Chris@0 820 @request.session[:user_id] = 2
chris@37 821 get :show, :project_id => 1
Chris@0 822 assert_response :success
Chris@0 823 assert_template 'show'
Chris@0 824 assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
Chris@0 825 end
Chris@441 826
Chris@0 827 def test_show_page_without_edit_link
Chris@0 828 @request.session[:user_id] = 4
chris@37 829 get :show, :project_id => 1
Chris@0 830 assert_response :success
Chris@0 831 assert_template 'show'
Chris@0 832 assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
Chris@441 833 end
Chris@441 834
Chris@909 835 def test_show_pdf
Chris@909 836 @request.session[:user_id] = 2
Chris@909 837 get :show, :project_id => 1, :format => 'pdf'
Chris@909 838 assert_response :success
Chris@909 839 assert_not_nil assigns(:page)
Chris@909 840 assert_equal 'application/pdf', @response.content_type
Chris@909 841 assert_equal 'attachment; filename="CookBook_documentation.pdf"',
Chris@909 842 @response.headers['Content-Disposition']
Chris@909 843 end
Chris@909 844
Chris@909 845 def test_show_html
Chris@909 846 @request.session[:user_id] = 2
Chris@909 847 get :show, :project_id => 1, :format => 'html'
Chris@909 848 assert_response :success
Chris@909 849 assert_not_nil assigns(:page)
Chris@909 850 assert_equal 'text/html', @response.content_type
Chris@909 851 assert_equal 'attachment; filename="CookBook_documentation.html"',
Chris@909 852 @response.headers['Content-Disposition']
Chris@1115 853 assert_tag 'h1', :content => 'CookBook documentation'
Chris@1115 854 end
Chris@1115 855
Chris@1115 856 def test_show_versioned_html
Chris@1115 857 @request.session[:user_id] = 2
Chris@1115 858 get :show, :project_id => 1, :format => 'html', :version => 2
Chris@1115 859 assert_response :success
Chris@1115 860 assert_not_nil assigns(:content)
Chris@1115 861 assert_equal 2, assigns(:content).version
Chris@1115 862 assert_equal 'text/html', @response.content_type
Chris@1115 863 assert_equal 'attachment; filename="CookBook_documentation.html"',
Chris@1115 864 @response.headers['Content-Disposition']
Chris@1115 865 assert_tag 'h1', :content => 'CookBook documentation'
Chris@909 866 end
Chris@909 867
Chris@909 868 def test_show_txt
Chris@909 869 @request.session[:user_id] = 2
Chris@909 870 get :show, :project_id => 1, :format => 'txt'
Chris@909 871 assert_response :success
Chris@909 872 assert_not_nil assigns(:page)
Chris@909 873 assert_equal 'text/plain', @response.content_type
Chris@909 874 assert_equal 'attachment; filename="CookBook_documentation.txt"',
Chris@909 875 @response.headers['Content-Disposition']
Chris@1115 876 assert_include 'h1. CookBook documentation', @response.body
Chris@1115 877 end
Chris@1115 878
Chris@1115 879 def test_show_versioned_txt
Chris@1115 880 @request.session[:user_id] = 2
Chris@1115 881 get :show, :project_id => 1, :format => 'txt', :version => 2
Chris@1115 882 assert_response :success
Chris@1115 883 assert_not_nil assigns(:content)
Chris@1115 884 assert_equal 2, assigns(:content).version
Chris@1115 885 assert_equal 'text/plain', @response.content_type
Chris@1115 886 assert_equal 'attachment; filename="CookBook_documentation.txt"',
Chris@1115 887 @response.headers['Content-Disposition']
Chris@1115 888 assert_include 'h1. CookBook documentation', @response.body
Chris@909 889 end
Chris@909 890
Chris@0 891 def test_edit_unprotected_page
Chris@0 892 # Non members can edit unprotected wiki pages
Chris@0 893 @request.session[:user_id] = 4
chris@37 894 get :edit, :project_id => 1, :id => 'Another_page'
Chris@0 895 assert_response :success
Chris@0 896 assert_template 'edit'
Chris@0 897 end
Chris@441 898
Chris@0 899 def test_edit_protected_page_by_nonmember
Chris@0 900 # Non members can't edit protected wiki pages
Chris@0 901 @request.session[:user_id] = 4
chris@37 902 get :edit, :project_id => 1, :id => 'CookBook_documentation'
Chris@0 903 assert_response 403
Chris@0 904 end
Chris@441 905
Chris@0 906 def test_edit_protected_page_by_member
Chris@0 907 @request.session[:user_id] = 2
chris@37 908 get :edit, :project_id => 1, :id => 'CookBook_documentation'
Chris@0 909 assert_response :success
Chris@441 910 assert_template 'edit'
Chris@0 911 end
Chris@441 912
Chris@0 913 def test_history_of_non_existing_page_should_return_404
chris@37 914 get :history, :project_id => 1, :id => 'Unknown_page'
Chris@0 915 assert_response 404
Chris@0 916 end
Chris@1115 917
Chris@1115 918 def test_add_attachment
Chris@1115 919 @request.session[:user_id] = 2
Chris@1115 920 assert_difference 'Attachment.count' do
Chris@1115 921 post :add_attachment, :project_id => 1, :id => 'CookBook_documentation',
Chris@1115 922 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
Chris@1115 923 end
Chris@1115 924 attachment = Attachment.first(:order => 'id DESC')
Chris@1115 925 assert_equal Wiki.find(1).find_page('CookBook_documentation'), attachment.container
Chris@1115 926 end
Chris@0 927 end