Ordering wiki pages should not be case sensitive (#31287).

Patch by Yuichi HARADA.


git-svn-id: http://svn.redmine.org/redmine/trunk@19831 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2020-06-20 06:50:28 +00:00
parent ba6ef9b5b6
commit 925fbe9263
4 changed files with 19 additions and 6 deletions

View File

@@ -306,7 +306,6 @@ class WikiController < ApplicationController
# Export wiki to a single pdf or html file
def export
@pages = @wiki.pages.
order('title').
includes([:content, {:attachments => :author}]).
to_a
respond_to do |format|
@@ -391,7 +390,6 @@ class WikiController < ApplicationController
def load_pages_for_index
@pages = @wiki.pages.with_updated_on.
reorder("#{WikiPage.table_name}.title").
includes(:wiki => :project).
includes(:parent).
to_a

View File

@@ -20,7 +20,7 @@
class Wiki < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :project
has_many :pages, lambda {order('title')}, :class_name => 'WikiPage', :dependent => :destroy
has_many :pages, lambda {order(Arel.sql('LOWER(title)').asc)}, :class_name => 'WikiPage', :dependent => :destroy
has_many :redirects, :class_name => 'WikiRedirect'
acts_as_watchable

View File

@@ -995,11 +995,11 @@ class WikiControllerTest < Redmine::ControllerTest
end
assert_select 'ul.pages-hierarchy' do
assert_select 'li' do
assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation', :text => 'CookBook documentation'
assert_select 'li:nth-child(1) > a[href=?]', '/projects/ecookbook/wiki/Another_page', :text => 'Another page'
assert_select 'li:nth-child(2)' do
assert_select '> a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation', :text => 'CookBook documentation'
assert_select 'ul li a[href=?]', '/projects/ecookbook/wiki/Page_with_an_inline_image', :text => 'Page with an inline image'
end
assert_select 'li a[href=?]', '/projects/ecookbook/wiki/Another_page', :text => 'Another page'
end
end
@@ -1015,6 +1015,11 @@ class WikiControllerTest < Redmine::ControllerTest
assert_response :success
assert_equal "text/html", @response.media_type
assert_select 'ul.pages-hierarchy' do
assert_select 'li:nth-child(1) > a[href=?]', '#Another_page', :text => 'Another page'
assert_select 'li:nth-child(2) > a[href=?]', '#CookBook_documentation', :text => 'CookBook documentation'
assert_select 'li:nth-child(3) > a[href=?]', '#Page_with_sections', :text => 'Page with sections'
end
assert_select "a[name=?]", "CookBook_documentation"
assert_select "a[name=?]", "Another_page"
assert_select "a[name=?]", "Page_with_an_inline_image"

View File

@@ -52,6 +52,16 @@ class WikiTest < ActiveSupport::TestCase
assert_equal page, wiki.find_page('ANOTHER page')
end
def test_ordering_pages_should_not_be_case_sensitive
wiki = Wiki.find(1)
wiki.pages.destroy_all
%w(ABc ACd Aac Acc).each do |title|
wiki.pages.create(:title => title)
end
wiki.reload
assert_equal %w(Aac ABc Acc ACd), wiki.pages.pluck(:title)
end
def test_find_page_with_cyrillic_characters
wiki = Wiki.find(1)
page = WikiPage.find(10)