You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wiki_test.rb 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2020 Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. require File.expand_path('../../test_helper', __FILE__)
  19. class WikiIntegrationTest < Redmine::IntegrationTest
  20. fixtures :projects,
  21. :users, :email_addresses,
  22. :roles,
  23. :members,
  24. :member_roles,
  25. :trackers,
  26. :projects_trackers,
  27. :enabled_modules,
  28. :wikis,
  29. :wiki_pages,
  30. :wiki_contents
  31. def test_updating_a_renamed_page
  32. log_user('jsmith', 'jsmith')
  33. get '/projects/ecookbook/wiki'
  34. assert_response :success
  35. get '/projects/ecookbook/wiki/Wiki/edit'
  36. assert_response :success
  37. # this update should not end up with a loss of content
  38. put '/projects/ecookbook/wiki/Wiki', params: {
  39. content: {
  40. text: "# Wiki\r\n\r\ncontent", comments: ""
  41. },
  42. wiki_page: { parent_id: "" }
  43. }
  44. assert_redirected_to "/projects/ecookbook/wiki/Wiki"
  45. follow_redirect!
  46. assert_select 'div', /content/
  47. assert content = WikiContent.last
  48. # Let's assume somebody else, or the same user in another tab, renames the
  49. # page while it is being edited.
  50. post '/projects/ecookbook/wiki/Wiki/rename', params: { wiki_page: { title: "NewTitle" } }
  51. assert_redirected_to "/projects/ecookbook/wiki/NewTitle"
  52. # this update should not end up with a loss of content
  53. put '/projects/ecookbook/wiki/Wiki', params: {
  54. content: {
  55. version: content.version, text: "# Wiki\r\n\r\nnew content", comments: ""
  56. },
  57. wiki_page: { parent_id: "" }
  58. }
  59. assert_redirected_to "/projects/ecookbook/wiki/NewTitle"
  60. follow_redirect!
  61. assert_select 'div', /new content/
  62. end
  63. end