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_content_version_test.rb 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2014 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. end
  22. def test_destroy
  23. v = WikiContent::Version.find(2)
  24. assert_difference 'WikiContent::Version.count', -1 do
  25. v.destroy
  26. end
  27. end
  28. def test_destroy_last_version_should_revert_content
  29. v = WikiContent::Version.find(3)
  30. assert_no_difference 'WikiPage.count' do
  31. assert_no_difference 'WikiContent.count' do
  32. assert_difference 'WikiContent::Version.count', -1 do
  33. assert v.destroy
  34. end
  35. end
  36. end
  37. c = WikiContent.find(1)
  38. v = c.versions.last
  39. assert_equal 2, c.version
  40. assert_equal v.version, c.version
  41. assert_equal v.comments, c.comments
  42. assert_equal v.text, c.text
  43. assert_equal v.author, c.author
  44. assert_equal v.updated_on, c.updated_on
  45. end
  46. def test_destroy_all_versions_should_delete_page
  47. WikiContent::Version.find(1).destroy
  48. WikiContent::Version.find(2).destroy
  49. v = WikiContent::Version.find(3)
  50. assert_difference 'WikiPage.count', -1 do
  51. assert_difference 'WikiContent.count', -1 do
  52. assert_difference 'WikiContent::Version.count', -1 do
  53. assert v.destroy
  54. end
  55. end
  56. end
  57. assert_nil WikiPage.find_by_id(1)
  58. end
  59. end