##// END OF EJS Templates
Adds a test for #23242....
Jean-Philippe Lang -
r15229:07da3dc70cc4
parent child
Show More
@@ -1,68 +1,73
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2016 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class WikiContentVersionTest < ActiveSupport::TestCase
21 21 fixtures :projects, :users, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
22 22
23 23 def setup
24 24 end
25 25
26 def test_should_respond_to_attachments
27 v = WikiContent::Version.find(2)
28 assert v.respond_to?(:attachments)
29 end
30
26 31 def test_destroy
27 32 v = WikiContent::Version.find(2)
28 33
29 34 assert_difference 'WikiContent::Version.count', -1 do
30 35 v.destroy
31 36 end
32 37 end
33 38
34 39 def test_destroy_last_version_should_revert_content
35 40 v = WikiContent::Version.find(3)
36 41
37 42 assert_no_difference 'WikiPage.count' do
38 43 assert_no_difference 'WikiContent.count' do
39 44 assert_difference 'WikiContent::Version.count', -1 do
40 45 assert v.destroy
41 46 end
42 47 end
43 48 end
44 49 c = WikiContent.find(1)
45 50 v = c.versions.last
46 51 assert_equal 2, c.version
47 52 assert_equal v.version, c.version
48 53 assert_equal v.comments, c.comments
49 54 assert_equal v.text, c.text
50 55 assert_equal v.author, c.author
51 56 assert_equal v.updated_on, c.updated_on
52 57 end
53 58
54 59 def test_destroy_all_versions_should_delete_page
55 60 WikiContent::Version.find(1).destroy
56 61 WikiContent::Version.find(2).destroy
57 62 v = WikiContent::Version.find(3)
58 63
59 64 assert_difference 'WikiPage.count', -1 do
60 65 assert_difference 'WikiContent.count', -1 do
61 66 assert_difference 'WikiContent::Version.count', -1 do
62 67 assert v.destroy
63 68 end
64 69 end
65 70 end
66 71 assert_nil WikiPage.find_by_id(1)
67 72 end
68 73 end
General Comments 0
You need to be logged in to leave comments. Login now