Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

wiki_content_version_test.rb 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2017 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  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
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. require File.expand_path('../../test_helper', __FILE__)
  18. class WikiContentVersionTest < ActiveSupport::TestCase
  19. fixtures :projects, :users, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
  20. def setup
  21. User.current = nil
  22. end
  23. def test_should_respond_to_attachments
  24. v = WikiContentVersion.find(2)
  25. assert v.respond_to?(:attachments)
  26. end
  27. def test_destroy
  28. v = WikiContentVersion.find(2)
  29. assert_difference 'WikiContentVersion.count', -1 do
  30. v.destroy
  31. end
  32. end
  33. def test_destroy_last_version_should_revert_content
  34. v = WikiContentVersion.find(3)
  35. assert_no_difference 'WikiPage.count' do
  36. assert_no_difference 'WikiContent.count' do
  37. assert_difference 'WikiContentVersion.count', -1 do
  38. assert v.destroy
  39. end
  40. end
  41. end
  42. c = WikiContent.find(1)
  43. v = c.versions.last
  44. assert_equal 2, c.version
  45. assert_equal v.version, c.version
  46. assert_equal v.comments, c.comments
  47. assert_equal v.text, c.text
  48. assert_equal v.author, c.author
  49. assert_equal v.updated_on, c.updated_on
  50. end
  51. def test_destroy_all_versions_should_delete_page
  52. WikiContentVersion.find(1).destroy
  53. WikiContentVersion.find(2).destroy
  54. v = WikiContentVersion.find(3)
  55. assert_difference 'WikiPage.count', -1 do
  56. assert_difference 'WikiContent.count', -1 do
  57. assert_difference 'WikiContentVersion.count', -1 do
  58. assert v.destroy
  59. end
  60. end
  61. end
  62. assert_nil WikiPage.find_by_id(1)
  63. end
  64. end