annotate .svn/pristine/14/147267197c59e4171e424ec83498747a79bcc270.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

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