diff --git a/app/models/approve_article.rb b/app/models/approve_article.rb index 8681f65..915dc72 100644 --- a/app/models/approve_article.rb +++ b/app/models/approve_article.rb @@ -94,7 +94,11 @@ class ApproveArticle < Task end def target_notification_description - _('%{requestor} wants to publish the article: %{article}.') % {:requestor => requestor.name, :article => article.name} + if article + _('%{requestor} wants to publish the article: %{article}.') % {:requestor => requestor.name, :article => article.name} + else + _('%{requestor} wants to publish an article that was removed.') % {:requestor => requestor.name} + end end def target_notification_message diff --git a/features/approve_article.feature b/features/approve_article.feature index d0dcfd5..298541f 100644 --- a/features/approve_article.feature +++ b/features/approve_article.feature @@ -11,6 +11,7 @@ Feature: approve article And the following articles | owner | name | body | homepage | | mariasilva | Sample Article | This is an article | true | + | mariasilva | Dub Wars | This is an article | false | And the following communities | identifier | name | | sample-community | Sample Community | @@ -51,3 +52,21 @@ Feature: approve article And I press "Apply!" When I go to Sample Community's sitemap Then I should not see "Sample Article" + + @selenium + Scenario: reject an article that was removed + Given I am logged in as "mariasilva" + And I follow "Dub Wars" + And I follow "Spread" and wait + And I check "Sample Community" + And I press "Spread this" + And I follow "Delete" + And I press "Yes, I want." + When I am logged in as "joaosilva" + And I go to Sample Community's control panel + And I follow "Process requests" and wait + And I choose "Reject" + And I fill in "Rejection explanation" with "Article was removed." + And I press "Apply!" + Then I should see "No pending tasks" + And I should not see "You have a nil object when you didn't expect it" diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index 1591c73..5140f8d 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -65,7 +65,7 @@ Given /^the following (articles|events|blogs|folders|forums|galleries)$/ do |con result.parent = Article.find_by_name(parent) end result.save! - if home + if home == 'true' owner.home_page = result owner.save! end diff --git a/script/sample-profiles b/script/sample-profiles index 6f85dec..14d2226 100755 --- a/script/sample-profiles +++ b/script/sample-profiles @@ -120,3 +120,15 @@ admin = User.create!({ :environment => environment, }).person environment.add_admin(admin) + +guest = User.create!({ + :login => "guest", + :email => 'guest@localhost.localdomain', + :password => 'guest', + :password_confirmation => 'guest', + :environment => environment, +}).person +5.times do + communities.rand.add_admin(guest) + communities.rand.add_member(guest) +end diff --git a/test/unit/approve_article_test.rb b/test/unit/approve_article_test.rb index f5b7c07..a6e03f3 100644 --- a/test/unit/approve_article_test.rb +++ b/test/unit/approve_article_test.rb @@ -370,6 +370,15 @@ class ApproveArticleTest < ActiveSupport::TestCase assert_match(/#{task.requestor.name} wants to publish the article: #{article.name}/, email.subject) end + should 'deliver target finished message about article deleted' do + task = ApproveArticle.new(:article => article, :target => community, :requestor => profile) + article.destroy + + email = TaskMailer.deliver_task_finished(task) + + assert_match(/#{task.requestor.name} wants to publish an article that was removed/, email.subject) + end + should 'approve an event' do event = fast_create(Event, :profile_id => profile.id, :name => 'Event test', :slug => 'event-test', :abstract => 'Lead of article', :body => 'This is my event') task = ApproveArticle.create!(:name => 'Event test', :article => event, :target => community, :requestor => profile) -- libgit2 0.21.2