diff --git a/app/models/approve_article.rb b/app/models/approve_article.rb index 31e134f..44444ac 100644 --- a/app/models/approve_article.rb +++ b/app/models/approve_article.rb @@ -4,7 +4,11 @@ class ApproveArticle < Task validates_presence_of :requestor_id, :target_id def description - _('%{author} wants to publish "%{article}" on %{community}') % { :author => requestor.name, :article => article.title, :community => target.name } + _('%{author} wants to publish "%{article}" on %{community}') % { :author => requestor.name, :article => article_title, :community => target.name } + end + + def article_title + article ? article.title : _('(The original text was removed)') end def data diff --git a/test/unit/approve_article_test.rb b/test/unit/approve_article_test.rb index ddbe486..754764c 100644 --- a/test/unit/approve_article_test.rb +++ b/test/unit/approve_article_test.rb @@ -50,4 +50,17 @@ class ApproveArticleTest < ActiveSupport::TestCase assert_nil a.article_parent end + + should 'alert when reference article is removed' do + profile = create_user('test_user').person + article = profile.articles.create!(:name => 'test article') + + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile) + + article.destroy + a.reload + + assert_match /text was removed/, a.description + end + end -- libgit2 0.21.2