Commit 6ec69965ca3d6d7e79ef6e76661962ce525dec47
1 parent
3a4726cb
Exists in
master
and in
22 other branches
Fix pagination for parent contents at context content block
Showing
2 changed files
with
19 additions
and
1 deletions
Show diff stats
plugins/context_content/lib/context_content_block.rb
| ... | ... | @@ -41,7 +41,7 @@ class ContextContentBlock < Block |
| 41 | 41 | return @children unless @children.blank? |
| 42 | 42 | if page |
| 43 | 43 | @children = page.children.with_types(types).paginate(:per_page => limit, :page => p) |
| 44 | - (@children.blank? && show_parent_content) ? contents(page.parent) : @children | |
| 44 | + (@children.blank? && show_parent_content) ? contents(page.parent, p) : @children | |
| 45 | 45 | else |
| 46 | 46 | nil |
| 47 | 47 | end | ... | ... |
plugins/context_content/test/unit/context_content_block_test.rb
| ... | ... | @@ -48,6 +48,24 @@ class ContextContentBlockTest < ActiveSupport::TestCase |
| 48 | 48 | assert_equal 2, @block.contents(folder).length |
| 49 | 49 | end |
| 50 | 50 | |
| 51 | + should 'show contents for next page' do | |
| 52 | + @block.limit = 2 | |
| 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) | |
| 57 | + assert_equal [article3], @block.contents(folder, 2) | |
| 58 | + end | |
| 59 | + | |
| 60 | + should 'show parent contents for next page' do | |
| 61 | + @block.limit = 2 | |
| 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) | |
| 66 | + assert_equal [article3], @block.contents(article1, 2) | |
| 67 | + end | |
| 68 | + | |
| 51 | 69 | should 'return parent children if page has no children' do |
| 52 | 70 | folder = fast_create(Folder) |
| 53 | 71 | article = fast_create(TinyMceArticle, :parent_id => folder.id) | ... | ... |