@@ -45,11 +45,11 class Wiki < ActiveRecord::Base | |||||
45 | # find the page with the given title |
|
45 | # find the page with the given title | |
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 ?", title]) |
|
49 | page = pages.first(:conditions => ["LOWER(title) LIKE 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 ?", title]) |
|
52 | redirect = redirects.first(:conditions => ["LOWER(title) LIKE 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 |
@@ -62,4 +62,10 wiki_pages_009: | |||||
62 | wiki_id: 2 |
|
62 | wiki_id: 2 | |
63 | protected: false |
|
63 | protected: false | |
64 | parent_id: 8 |
|
64 | parent_id: 8 | |
65 | No newline at end of file |
|
65 | wiki_pages_010: | |
|
66 | created_on: 2007-03-08 00:18:07 +01:00 | |||
|
67 | title: Этика_менеджмента | |||
|
68 | id: 10 | |||
|
69 | wiki_id: 1 | |||
|
70 | protected: false | |||
|
71 | parent_id: |
@@ -46,6 +46,9 class WikiTest < ActiveSupport::TestCase | |||||
46 | assert_equal page, wiki.find_page('Another_page') |
|
46 | assert_equal page, wiki.find_page('Another_page') | |
47 | assert_equal page, wiki.find_page('Another page') |
|
47 | assert_equal page, wiki.find_page('Another page') | |
48 | assert_equal page, wiki.find_page('ANOTHER page') |
|
48 | assert_equal page, wiki.find_page('ANOTHER page') | |
|
49 | ||||
|
50 | page = WikiPage.find(10) | |||
|
51 | assert_equal page, wiki.find_page('Этика_менеджмента') | |||
49 | end |
|
52 | end | |
50 |
|
53 | |||
51 | def test_titleize |
|
54 | def test_titleize |
General Comments 0
You need to be logged in to leave comments.
Login now