Commit fd9ed84e2b1b5b5cb4815143330fee124c27b327
Committed by
Antonio Terceiro
1 parent
737bb9ad
Exists in
master
and in
29 other branches
ActionItem1185: published article handles blanl names
Showing
4 changed files
with
40 additions
and
2 deletions
Show diff stats
app/models/approve_article.rb
app/models/published_article.rb
test/functional/tasks_controller_test.rb
... | ... | @@ -203,4 +203,24 @@ class TasksControllerTest < Test::Unit::TestCase |
203 | 203 | assert_not_nil PublishedArticle.find(:first) |
204 | 204 | end |
205 | 205 | |
206 | + should 'handle blank names for published articles' do | |
207 | + c = Community.create!(:name => 'test comm') | |
208 | + @controller.stubs(:profile).returns(c) | |
209 | + c.affiliate(profile, Profile::Roles.all_roles(c.environment)) | |
210 | + person = create_user('test_user').person | |
211 | + p_blog = Blog.create!(:profile => person) | |
212 | + c_blog1 = Blog.create!(:profile => c) | |
213 | + c_blog2 = Blog.new(:profile => c); c_blog2.name = 'blog2'; c_blog2.save! | |
214 | + | |
215 | + article = person.articles.create!(:name => 'test article', :parent => p_blog) | |
216 | + a = ApproveArticle.create!(:article => article, :target => c, :requestor => person) | |
217 | + assert_includes c.tasks, a | |
218 | + | |
219 | + assert_difference PublishedArticle, :count do | |
220 | + post :close, {"commit"=>"Ok!", "id"=> a.id.to_s, "task"=>{"name"=>"", "closing_statment"=>"", "highlighted"=>"0", "article_parent_id"=>c_blog2.id.to_s}, "decision"=>"finish"} | |
221 | + end | |
222 | + assert p_article = PublishedArticle.find_by_reference_article_id(article.id) | |
223 | + assert_includes c_blog2.children(true), p_article | |
224 | + end | |
225 | + | |
206 | 226 | end | ... | ... |
test/unit/approve_article_test.rb
... | ... | @@ -63,4 +63,22 @@ class ApproveArticleTest < ActiveSupport::TestCase |
63 | 63 | assert_match /text was removed/, a.description |
64 | 64 | end |
65 | 65 | |
66 | + should 'preserve article_parent' do | |
67 | + profile = create_user('test_user').person | |
68 | + article = profile.articles.create!(:name => 'test article') | |
69 | + a = ApproveArticle.new(:article_parent => article) | |
70 | + | |
71 | + assert_equal article, a.article_parent | |
72 | + end | |
73 | + | |
74 | + should 'handle blank names' do | |
75 | + profile = create_user('test_user').person | |
76 | + article = profile.articles.create!(:name => 'test article') | |
77 | + community = Community.create!(:name => 'test comm') | |
78 | + a = ApproveArticle.create!(:name => '', :article => article, :target => community, :requestor => profile) | |
79 | + | |
80 | + assert_difference PublishedArticle, :count do | |
81 | + a.finish | |
82 | + end | |
83 | + end | |
66 | 84 | end | ... | ... |