Commit 9fe54f9ef329165a7eba27e5dfd07aa589aa3ea1
Committed by
Antonio Terceiro
1 parent
62b11ca9
Exists in
master
and in
29 other branches
ActionItem1189: published article goes to selected folder
Showing
2 changed files
with
17 additions
and
3 deletions
Show diff stats
app/models/published_article.rb
1 | class PublishedArticle < Article | 1 | class PublishedArticle < Article |
2 | before_create do |article| | 2 | before_create do |article| |
3 | - parent = article.reference_article.parent | ||
4 | - if parent && parent.blog? && article.profile.has_blog? | ||
5 | - article.parent = article.profile.blog | 3 | + unless article.parent |
4 | + parent = article.reference_article.parent | ||
5 | + if parent && parent.blog? && article.profile.has_blog? | ||
6 | + article.parent = article.profile.blog | ||
7 | + end | ||
6 | end | 8 | end |
7 | end | 9 | end |
8 | 10 |
test/unit/published_article_test.rb
@@ -110,4 +110,16 @@ class PublishedArticleTest < ActiveSupport::TestCase | @@ -110,4 +110,16 @@ class PublishedArticleTest < ActiveSupport::TestCase | ||
110 | 110 | ||
111 | assert_match /removed/, p.to_html | 111 | assert_match /removed/, p.to_html |
112 | end | 112 | end |
113 | + | ||
114 | + should 'specified parent overwrite blog' do | ||
115 | + parent = mock | ||
116 | + @article.stubs(:parent).returns(parent) | ||
117 | + parent.stubs(:blog?).returns(true) | ||
118 | + prof = Community.create!(:name => 'test_comm', :identifier => 'test_comm') | ||
119 | + prof.articles << Blog.new(:profile => prof, :name => 'Blog test') | ||
120 | + new_parent = Folder.create!(:profile => prof, :name => 'Folder test') | ||
121 | + p = PublishedArticle.create!(:reference_article => @article, :profile => prof, :parent => new_parent) | ||
122 | + | ||
123 | + assert_equal p.parent, new_parent | ||
124 | + end | ||
113 | end | 125 | end |