Commit 76fd7b7c02f6242dac0f754cd219b641e0e7683d
Committed by
Antonio Terceiro
1 parent
64622c39
Exists in
master
and in
29 other branches
ActionItem1180: made task alert removed articles
Showing
2 changed files
with
18 additions
and
1 deletions
Show diff stats
app/models/approve_article.rb
@@ -4,7 +4,11 @@ class ApproveArticle < Task | @@ -4,7 +4,11 @@ class ApproveArticle < Task | ||
4 | validates_presence_of :requestor_id, :target_id | 4 | validates_presence_of :requestor_id, :target_id |
5 | 5 | ||
6 | def description | 6 | def description |
7 | - _('%{author} wants to publish "%{article}" on %{community}') % { :author => requestor.name, :article => article.title, :community => target.name } | 7 | + _('%{author} wants to publish "%{article}" on %{community}') % { :author => requestor.name, :article => article_title, :community => target.name } |
8 | + end | ||
9 | + | ||
10 | + def article_title | ||
11 | + article ? article.title : _('(The original text was removed)') | ||
8 | end | 12 | end |
9 | 13 | ||
10 | def data | 14 | def data |
test/unit/approve_article_test.rb
@@ -50,4 +50,17 @@ class ApproveArticleTest < ActiveSupport::TestCase | @@ -50,4 +50,17 @@ class ApproveArticleTest < ActiveSupport::TestCase | ||
50 | 50 | ||
51 | assert_nil a.article_parent | 51 | assert_nil a.article_parent |
52 | end | 52 | end |
53 | + | ||
54 | + should 'alert when reference article is removed' do | ||
55 | + profile = create_user('test_user').person | ||
56 | + article = profile.articles.create!(:name => 'test article') | ||
57 | + | ||
58 | + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile) | ||
59 | + | ||
60 | + article.destroy | ||
61 | + a.reload | ||
62 | + | ||
63 | + assert_match /text was removed/, a.description | ||
64 | + end | ||
65 | + | ||
53 | end | 66 | end |