comparison .svn/pristine/a1/a15efc0a7b7f938a7d937205168f8739fcc6338f.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 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
18 require File.expand_path('../../test_helper', __FILE__)
19
20 class WikiContentVersionTest < ActiveSupport::TestCase
21 fixtures :projects, :users, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
22
23 def setup
24 end
25
26 def test_destroy
27 v = WikiContent::Version.find(2)
28
29 assert_difference 'WikiContent::Version.count', -1 do
30 v.destroy
31 end
32 end
33
34 def test_destroy_last_version_should_revert_content
35 v = WikiContent::Version.find(3)
36
37 assert_no_difference 'WikiPage.count' do
38 assert_no_difference 'WikiContent.count' do
39 assert_difference 'WikiContent::Version.count', -1 do
40 assert v.destroy
41 end
42 end
43 end
44 c = WikiContent.find(1)
45 v = c.versions.last
46 assert_equal 2, c.version
47 assert_equal v.version, c.version
48 assert_equal v.comments, c.comments
49 assert_equal v.text, c.text
50 assert_equal v.author, c.author
51 assert_equal v.updated_on, c.updated_on
52 end
53
54 def test_destroy_all_versions_should_delete_page
55 WikiContent::Version.find(1).destroy
56 WikiContent::Version.find(2).destroy
57 v = WikiContent::Version.find(3)
58
59 assert_difference 'WikiPage.count', -1 do
60 assert_difference 'WikiContent.count', -1 do
61 assert_difference 'WikiContent::Version.count', -1 do
62 assert v.destroy
63 end
64 end
65 end
66 assert_nil WikiPage.find_by_id(1)
67 end
68 end