##// END OF EJS Templates
Fixed: wiki page with backslash in title can not be found (#7589)....
Jean-Philippe Lang -
r4977:f7127e946686
parent child
Show More
@@ -46,10 +46,10 class Wiki < ActiveRecord::Base
46 def find_page(title, options = {})
46 def find_page(title, options = {})
47 title = start_page if title.blank?
47 title = start_page if title.blank?
48 title = Wiki.titleize(title)
48 title = Wiki.titleize(title)
49 page = pages.first(:conditions => ["LOWER(title) LIKE LOWER(?)", title])
49 page = pages.first(:conditions => ["LOWER(title) = LOWER(?)", title])
50 if !page && !(options[:with_redirect] == false)
50 if !page && !(options[:with_redirect] == false)
51 # search for a redirect
51 # search for a redirect
52 redirect = redirects.first(:conditions => ["LOWER(title) LIKE LOWER(?)", title])
52 redirect = redirects.first(:conditions => ["LOWER(title) = LOWER(?)", title])
53 page = find_page(redirect.redirects_to, :with_redirect => false) if redirect
53 page = find_page(redirect.redirects_to, :with_redirect => false) if redirect
54 end
54 end
55 page
55 page
@@ -20,7 +20,7
20 require File.expand_path('../../test_helper', __FILE__)
20 require File.expand_path('../../test_helper', __FILE__)
21
21
22 class WikiTest < ActiveSupport::TestCase
22 class WikiTest < ActiveSupport::TestCase
23 fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
23 fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
24
24
25 def test_create
25 def test_create
26 wiki = Wiki.new(:project => Project.find(2))
26 wiki = Wiki.new(:project => Project.find(2))
@@ -49,6 +49,9 class WikiTest < ActiveSupport::TestCase
49
49
50 page = WikiPage.find(10)
50 page = WikiPage.find(10)
51 assert_equal page, wiki.find_page('Этика_менеджмента')
51 assert_equal page, wiki.find_page('Этика_менеджмента')
52
53 page = WikiPage.generate!(:wiki => wiki, :title => '2009\\02\\09')
54 assert_equal page, wiki.find_page('2009\\02\\09')
52 end
55 end
53
56
54 def test_titleize
57 def test_titleize
General Comments 0
You need to be logged in to leave comments. Login now