Commit 37e8887a89acef33b1f006a772c5e0c41fa6f823
1 parent
a5c0c0f3
Exists in
master
and in
29 other branches
display_content: fix edition when a selected article was removed
Showing
2 changed files
with
16 additions
and
1 deletions
Show diff stats
plugins/display_content/lib/display_content_block.rb
... | ... | @@ -56,7 +56,7 @@ class DisplayContentBlock < Block |
56 | 56 | end |
57 | 57 | |
58 | 58 | def parent_nodes |
59 | - @parent_nodes ||= self.holder.articles.find(nodes).map { |article| get_parent(article) }.compact.flatten | |
59 | + @parent_nodes ||= self.holder.articles.where(:id => nodes).map { |article| get_parent(article) }.compact.flatten | |
60 | 60 | end |
61 | 61 | |
62 | 62 | VALID_CONTENT = ['RawHTMLArticle', 'TextArticle', 'TextileArticle', 'TinyMceArticle', 'Folder', 'Blog', 'Forum'] | ... | ... |
plugins/display_content/test/unit/display_content_block_test.rb
... | ... | @@ -557,4 +557,19 @@ class DisplayContentBlockTest < ActiveSupport::TestCase |
557 | 557 | assert_equal [a1], block.articles_of_parent |
558 | 558 | end |
559 | 559 | |
560 | + should 'do not fail if a selected article was removed' do | |
561 | + profile = create_user('testuser').person | |
562 | + Article.delete_all | |
563 | + f1 = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) | |
564 | + a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f1.id) | |
565 | + | |
566 | + checked_articles= {a1.id => true} | |
567 | + | |
568 | + block = DisplayContentBlock.new | |
569 | + block.stubs(:holder).returns(profile) | |
570 | + block.checked_nodes= checked_articles | |
571 | + a1.destroy | |
572 | + assert_equal [], block.parent_nodes | |
573 | + end | |
574 | + | |
560 | 575 | end | ... | ... |