@@ -1,68 +1,68 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2012 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 | class WikiContentTest < ActiveSupport::TestCase | |
|
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 | 26 | def test_destroy |
|
27 | 27 | v = WikiContent::Version.find(2) |
|
28 | 28 | |
|
29 | 29 | assert_difference 'WikiContent::Version.count', -1 do |
|
30 | 30 | v.destroy |
|
31 | 31 | end |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | def test_destroy_last_version_should_revert_content |
|
35 | 35 | v = WikiContent::Version.find(3) |
|
36 | 36 | |
|
37 | 37 | assert_no_difference 'WikiPage.count' do |
|
38 | 38 | assert_no_difference 'WikiContent.count' do |
|
39 | 39 | assert_difference 'WikiContent::Version.count', -1 do |
|
40 | 40 | assert v.destroy |
|
41 | 41 | end |
|
42 | 42 | end |
|
43 | 43 | end |
|
44 | 44 | c = WikiContent.find(1) |
|
45 | 45 | v = c.versions.last |
|
46 | 46 | assert_equal 2, c.version |
|
47 | 47 | assert_equal v.version, c.version |
|
48 | 48 | assert_equal v.comments, c.comments |
|
49 | 49 | assert_equal v.text, c.text |
|
50 | 50 | assert_equal v.author, c.author |
|
51 | 51 | assert_equal v.updated_on, c.updated_on |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | 54 | def test_destroy_all_versions_should_delete_page |
|
55 | 55 | WikiContent::Version.find(1).destroy |
|
56 | 56 | WikiContent::Version.find(2).destroy |
|
57 | 57 | v = WikiContent::Version.find(3) |
|
58 | 58 | |
|
59 | 59 | assert_difference 'WikiPage.count', -1 do |
|
60 | 60 | assert_difference 'WikiContent.count', -1 do |
|
61 | 61 | assert_difference 'WikiContent::Version.count', -1 do |
|
62 | 62 | assert v.destroy |
|
63 | 63 | end |
|
64 | 64 | end |
|
65 | 65 | end |
|
66 | 66 | assert_nil WikiPage.find_by_id(1) |
|
67 | 67 | end |
|
68 | 68 | end |
General Comments 0
You need to be logged in to leave comments.
Login now