]> source.dussan.org Git - redmine.git/commitdiff
Fixed: Wiki#find_page should not be case sensitive because page title uniqueness...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 27 Nov 2010 11:14:28 +0000 (11:14 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 27 Nov 2010 11:14:28 +0000 (11:14 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4430 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/wiki.rb
test/unit/wiki_redirect_test.rb
test/unit/wiki_test.rb

index 9bd24595599981ff7ef172636e786664ef48ff83..b28694ec48d45435ac144864398fc85d8c484a2f 100644 (file)
@@ -45,11 +45,11 @@ class Wiki < ActiveRecord::Base
   # find the page with the given title
   def find_page(title, options = {})
     title = start_page if title.blank?
-    title = Wiki.titleize(title)
-    page = pages.find_by_title(title)
+    title = Wiki.titleize(title).downcase
+    page = pages.first(:conditions => ["LOWER(title) LIKE ?", title])
     if !page && !(options[:with_redirect] == false)
       # search for a redirect
-      redirect = redirects.find_by_title(title)
+      redirect = redirects.first(:conditions => ["LOWER(title) LIKE ?", title])
       page = find_page(redirect.redirects_to, :with_redirect => false) if redirect
     end
     page
index 7e80638b2c235b4ccb7ea28cacf49edb274ec450..3e19d4958e2e364113e5365a4c4a9b7fb7691cdd 100644 (file)
@@ -18,7 +18,7 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class WikiRedirectTest < ActiveSupport::TestCase
-  fixtures :projects, :wikis
+  fixtures :projects, :wikis, :wiki_pages
 
   def setup
     @wiki = Wiki.find(1)
@@ -33,6 +33,7 @@ class WikiRedirectTest < ActiveSupport::TestCase
     assert_equal 'New_title', @original.title
     assert @wiki.redirects.find_by_title('Original_title')
     assert @wiki.find_page('Original title')
+    assert @wiki.find_page('ORIGINAL title')
   end
   
   def test_update_redirect
index 9303ce7845c47bfd028ee54ff10d71ce81205f65..82a08b4c42bff92f5ae896a9b05f8fba6ffb5b61 100644 (file)
@@ -39,6 +39,15 @@ class WikiTest < ActiveSupport::TestCase
     assert_equal "Another start page", @wiki.start_page
   end
   
+  def test_find_page
+    wiki = Wiki.find(1)
+    page = WikiPage.find(2)
+    
+    assert_equal page, wiki.find_page('Another_page')
+    assert_equal page, wiki.find_page('Another page')
+    assert_equal page, wiki.find_page('ANOTHER page')
+  end
+  
   def test_titleize
     assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES')
     assert_equal 'テスト', Wiki.titleize('テスト')