diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 4c96221df..431769712 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -303,7 +303,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| @@ -388,7 +387,6 @@ private def load_pages_for_index @pages = @wiki.pages.with_updated_on. - reorder("#{WikiPage.table_name}.title"). includes(:wiki => :project). includes(:parent). to_a diff --git a/app/models/wiki.rb b/app/models/wiki.rb index ed4331f4e..0c9c0a629 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -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 diff --git a/app/views/wiki/export_multiple.html.erb b/app/views/wiki/export_multiple.html.erb index 6a9cf0f31..f5c535f39 100644 --- a/app/views/wiki/export_multiple.html.erb +++ b/app/views/wiki/export_multiple.html.erb @@ -22,7 +22,7 @@ h1:hover a.wiki-anchor, h2:hover a.wiki-anchor, h3:hover a.wiki-anchor { display <% @pages.each do |page| %>
- + <%= textilizable page.content ,:text, :wiki_links => :anchor, :only_path => false %> <% end %> diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 6ee3bff51..412b5fe07 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -989,11 +989,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 @@ -1009,6 +1009,11 @@ class WikiControllerTest < Redmine::ControllerTest assert_response :success assert_equal "text/html", @response.content_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" diff --git a/test/unit/wiki_test.rb b/test/unit/wiki_test.rb index b4ecd29bb..9184d4efc 100644 --- a/test/unit/wiki_test.rb +++ b/test/unit/wiki_test.rb @@ -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(Acc ABc Aace_ Aac).each do |title| + wiki.pages.create(:title => title) + end + wiki.reload + assert_equal %w(Aac Aace_ ABc Acc), wiki.pages.pluck(:title) + end + def test_find_page_with_cyrillic_characters wiki = Wiki.find(1) page = WikiPage.find(10)