Commit c4afac0b8977c1e4d693c9f4e78a990b678dc977
1 parent
793f7219
Exists in
master
and in
29 other branches
context_content: fix tests
Return children ordered by name to improve visualization and avoid test randomness.
Showing
2 changed files
with
7 additions
and
7 deletions
Show diff stats
plugins/context_content/lib/context_content_plugin/context_content_block.rb
@@ -58,7 +58,7 @@ class ContextContentPlugin::ContextContentBlock < Block | @@ -58,7 +58,7 @@ class ContextContentPlugin::ContextContentBlock < Block | ||
58 | def contents(page, p=1) | 58 | def contents(page, p=1) |
59 | return @children unless @children.blank? | 59 | return @children unless @children.blank? |
60 | if page | 60 | if page |
61 | - @children = page.children.with_types(types).paginate(:per_page => limit, :page => p) | 61 | + @children = page.children.with_types(types).order(:name).paginate(:per_page => limit, :page => p) |
62 | (@children.blank? && show_parent_content) ? contents(page.parent, p) : @children | 62 | (@children.blank? && show_parent_content) ? contents(page.parent, p) : @children |
63 | else | 63 | else |
64 | nil | 64 | nil |
plugins/context_content/test/unit/context_content_block_test.rb
@@ -51,18 +51,18 @@ class ContextContentBlockTest < ActiveSupport::TestCase | @@ -51,18 +51,18 @@ class ContextContentBlockTest < ActiveSupport::TestCase | ||
51 | should 'show contents for next page' do | 51 | should 'show contents for next page' do |
52 | @block.limit = 2 | 52 | @block.limit = 2 |
53 | folder = fast_create(Folder) | 53 | folder = fast_create(Folder) |
54 | - article1 = fast_create(TinyMceArticle, :parent_id => folder.id) | ||
55 | - article2 = fast_create(TinyMceArticle, :parent_id => folder.id) | ||
56 | - article3 = fast_create(TinyMceArticle, :parent_id => folder.id) | 54 | + article1 = fast_create(TinyMceArticle, :name => 'article 1', :parent_id => folder.id) |
55 | + article2 = fast_create(TinyMceArticle, :name => 'article 2', :parent_id => folder.id) | ||
56 | + article3 = fast_create(TinyMceArticle, :name => 'article 3', :parent_id => folder.id) | ||
57 | assert_equal [article3], @block.contents(folder, 2) | 57 | assert_equal [article3], @block.contents(folder, 2) |
58 | end | 58 | end |
59 | 59 | ||
60 | should 'show parent contents for next page' do | 60 | should 'show parent contents for next page' do |
61 | @block.limit = 2 | 61 | @block.limit = 2 |
62 | folder = fast_create(Folder) | 62 | folder = fast_create(Folder) |
63 | - article1 = fast_create(TinyMceArticle, :parent_id => folder.id) | ||
64 | - article2 = fast_create(TinyMceArticle, :parent_id => folder.id) | ||
65 | - article3 = fast_create(TinyMceArticle, :parent_id => folder.id) | 63 | + article1 = fast_create(TinyMceArticle, :name => 'article 1', :parent_id => folder.id) |
64 | + article2 = fast_create(TinyMceArticle, :name => 'article 2', :parent_id => folder.id) | ||
65 | + article3 = fast_create(TinyMceArticle, :name => 'article 3', :parent_id => folder.id) | ||
66 | assert_equal [article3], @block.contents(article1, 2) | 66 | assert_equal [article3], @block.contents(article1, 2) |
67 | end | 67 | end |
68 | 68 |