diff --git a/plugins/context_content/lib/context_content_plugin/context_content_block.rb b/plugins/context_content/lib/context_content_plugin/context_content_block.rb index 4d9d947..9df6ead 100644 --- a/plugins/context_content/lib/context_content_plugin/context_content_block.rb +++ b/plugins/context_content/lib/context_content_plugin/context_content_block.rb @@ -58,7 +58,7 @@ class ContextContentPlugin::ContextContentBlock < Block def contents(page, p=1) return @children unless @children.blank? if page - @children = page.children.with_types(types).paginate(:per_page => limit, :page => p) + @children = page.children.with_types(types).order(:name).paginate(:per_page => limit, :page => p) (@children.blank? && show_parent_content) ? contents(page.parent, p) : @children else nil diff --git a/plugins/context_content/test/unit/context_content_block_test.rb b/plugins/context_content/test/unit/context_content_block_test.rb index a003921..1ecfa62 100644 --- a/plugins/context_content/test/unit/context_content_block_test.rb +++ b/plugins/context_content/test/unit/context_content_block_test.rb @@ -51,18 +51,18 @@ class ContextContentBlockTest < ActiveSupport::TestCase should 'show contents for next page' do @block.limit = 2 folder = fast_create(Folder) - article1 = fast_create(TinyMceArticle, :parent_id => folder.id) - article2 = fast_create(TinyMceArticle, :parent_id => folder.id) - article3 = fast_create(TinyMceArticle, :parent_id => folder.id) + article1 = fast_create(TinyMceArticle, :name => 'article 1', :parent_id => folder.id) + article2 = fast_create(TinyMceArticle, :name => 'article 2', :parent_id => folder.id) + article3 = fast_create(TinyMceArticle, :name => 'article 3', :parent_id => folder.id) assert_equal [article3], @block.contents(folder, 2) end should 'show parent contents for next page' do @block.limit = 2 folder = fast_create(Folder) - article1 = fast_create(TinyMceArticle, :parent_id => folder.id) - article2 = fast_create(TinyMceArticle, :parent_id => folder.id) - article3 = fast_create(TinyMceArticle, :parent_id => folder.id) + article1 = fast_create(TinyMceArticle, :name => 'article 1', :parent_id => folder.id) + article2 = fast_create(TinyMceArticle, :name => 'article 2', :parent_id => folder.id) + article3 = fast_create(TinyMceArticle, :name => 'article 3', :parent_id => folder.id) assert_equal [article3], @block.contents(article1, 2) end -- libgit2 0.21.2