comparison test/unit/wiki_redirect_test.rb @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents 8661b858af72
children 433d4f72a19b
comparison
equal deleted inserted replaced
908:c6c2cbd0afee 909:cbb26bc654de
1 # redMine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
8 # 8 #
9 # This program is distributed in the hope that it will be useful, 9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details. 12 # GNU General Public License for more details.
13 # 13 #
14 # You should have received a copy of the GNU General Public License 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 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. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 require File.expand_path('../../test_helper', __FILE__) 18 require File.expand_path('../../test_helper', __FILE__)
22 22
23 def setup 23 def setup
24 @wiki = Wiki.find(1) 24 @wiki = Wiki.find(1)
25 @original = WikiPage.create(:wiki => @wiki, :title => 'Original title') 25 @original = WikiPage.create(:wiki => @wiki, :title => 'Original title')
26 end 26 end
27 27
28 def test_create_redirect 28 def test_create_redirect
29 @original.title = 'New title' 29 @original.title = 'New title'
30 assert @original.save 30 assert @original.save
31 @original.reload 31 @original.reload
32 32
33 assert_equal 'New_title', @original.title 33 assert_equal 'New_title', @original.title
34 assert @wiki.redirects.find_by_title('Original_title') 34 assert @wiki.redirects.find_by_title('Original_title')
35 assert @wiki.find_page('Original title') 35 assert @wiki.find_page('Original title')
36 assert @wiki.find_page('ORIGINAL title') 36 assert @wiki.find_page('ORIGINAL title')
37 end 37 end
38 38
39 def test_update_redirect 39 def test_update_redirect
40 # create a redirect that point to this page 40 # create a redirect that point to this page
41 assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Original_title') 41 assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Original_title')
42 42
43 @original.title = 'New title' 43 @original.title = 'New title'
44 @original.save 44 @original.save
45 # make sure the old page now points to the new page 45 # make sure the old page now points to the new page
46 assert_equal 'New_title', @wiki.find_page('An old page').title 46 assert_equal 'New_title', @wiki.find_page('An old page').title
47 end 47 end
48 48
49 def test_reverse_rename 49 def test_reverse_rename
50 # create a redirect that point to this page 50 # create a redirect that point to this page
51 assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Original_title') 51 assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Original_title')
52 52
53 @original.title = 'An old page' 53 @original.title = 'An old page'
54 @original.save 54 @original.save
55 assert !@wiki.redirects.find_by_title_and_redirects_to('An_old_page', 'An_old_page') 55 assert !@wiki.redirects.find_by_title_and_redirects_to('An_old_page', 'An_old_page')
56 assert @wiki.redirects.find_by_title_and_redirects_to('Original_title', 'An_old_page') 56 assert @wiki.redirects.find_by_title_and_redirects_to('Original_title', 'An_old_page')
57 end 57 end
58 58
59 def test_rename_to_already_redirected 59 def test_rename_to_already_redirected
60 assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Other_page') 60 assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Other_page')
61 61
62 @original.title = 'An old page' 62 @original.title = 'An old page'
63 @original.save 63 @original.save
64 # this redirect have to be removed since 'An old page' page now exists 64 # this redirect have to be removed since 'An old page' page now exists
65 assert !@wiki.redirects.find_by_title_and_redirects_to('An_old_page', 'Other_page') 65 assert !@wiki.redirects.find_by_title_and_redirects_to('An_old_page', 'Other_page')
66 end 66 end
67 67
68 def test_redirects_removed_when_deleting_page 68 def test_redirects_removed_when_deleting_page
69 assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Original_title') 69 assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Original_title')
70 70
71 @original.destroy 71 @original.destroy
72 assert !@wiki.redirects.find(:first) 72 assert !@wiki.redirects.find(:first)
73 end 73 end
74 end 74 end