fixed-31287.patch

Yuichi HARADA, 2019-06-14 02:22

Download (4.15 KB)

View differences:

app/controllers/wiki_controller.rb
303 303
  # Export wiki to a single pdf or html file
304 304
  def export
305 305
    @pages = @wiki.pages.
306
                      order('title').
307 306
                      includes([:content, {:attachments => :author}]).
308 307
                      to_a
309 308
    respond_to do |format|
......
388 387

  
389 388
  def load_pages_for_index
390 389
    @pages = @wiki.pages.with_updated_on.
391
                reorder("#{WikiPage.table_name}.title").
392 390
                includes(:wiki => :project).
393 391
                includes(:parent).
394 392
                to_a
app/models/wiki.rb
20 20
class Wiki < ActiveRecord::Base
21 21
  include Redmine::SafeAttributes
22 22
  belongs_to :project
23
  has_many :pages, lambda {order('title')}, :class_name => 'WikiPage', :dependent => :destroy
23
  has_many :pages, lambda {order(Arel.sql('LOWER(title)').asc)}, :class_name => 'WikiPage', :dependent => :destroy
24 24
  has_many :redirects, :class_name => 'WikiRedirect'
25 25

  
26 26
  acts_as_watchable
app/views/wiki/export_multiple.html.erb
22 22

  
23 23
<% @pages.each do |page| %>
24 24
<hr />
25
<a name="<%= page.title %>" />
25
<a name="<%= page.title %>"></a>
26 26
<%= textilizable page.content ,:text, :wiki_links => :anchor, :only_path => false %>
27 27
<% end %>
28 28

  
test/functional/wiki_controller_test.rb
989 989
    end
990 990

  
991 991
    assert_select 'ul.pages-hierarchy' do
992
      assert_select 'li' do
993
        assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation', :text => 'CookBook documentation'
992
      assert_select 'li:nth-child(1) > a[href=?]', '/projects/ecookbook/wiki/Another_page', :text => 'Another page'
993
      assert_select 'li:nth-child(2)' do
994
        assert_select '> a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation', :text => 'CookBook documentation'
994 995
        assert_select 'ul li a[href=?]', '/projects/ecookbook/wiki/Page_with_an_inline_image', :text => 'Page with an inline image'
995 996
      end
996
      assert_select 'li a[href=?]', '/projects/ecookbook/wiki/Another_page', :text => 'Another page'
997 997
    end
998 998
  end
999 999

  
......
1009 1009
    assert_response :success
1010 1010
    assert_equal "text/html", @response.content_type
1011 1011

  
1012
    assert_select 'ul.pages-hierarchy' do
1013
      assert_select 'li:nth-child(1) > a[href=?]', '#Another_page', :text => 'Another page'
1014
      assert_select 'li:nth-child(2) > a[href=?]', '#CookBook_documentation', :text => 'CookBook documentation'
1015
      assert_select 'li:nth-child(3) > a[href=?]', '#Page_with_sections', :text => 'Page with sections'
1016
    end
1012 1017
    assert_select "a[name=?]", "CookBook_documentation"
1013 1018
    assert_select "a[name=?]", "Another_page"
1014 1019
    assert_select "a[name=?]", "Page_with_an_inline_image"
test/unit/wiki_test.rb
52 52
    assert_equal page, wiki.find_page('ANOTHER page')
53 53
  end
54 54

  
55
  def test_ordering_pages_should_not_be_case_sensitive
56
    wiki = Wiki.find(1)
57
    wiki.pages.destroy_all
58
    %w(Acc ABc Aace_ Aac).each do |title|
59
      wiki.pages.create(:title => title)
60
    end
61
    wiki.reload
62
    assert_equal %w(Aac Aace_ ABc Acc), wiki.pages.pluck(:title)
63
  end
64

  
55 65
  def test_find_page_with_cyrillic_characters
56 66
    wiki = Wiki.find(1)
57 67
    page = WikiPage.find(10)