Commit ef306ba96eeb773fb9a2299ac09bb1de83d6f522
Exists in
master
and in
23 other branches
Merge commit 'refs/merge-requests/24' of git://gitorious.org/noosfero/noosfero i…
…nto merge-requests/24
Showing
5 changed files
with
46 additions
and
2 deletions
Show diff stats
app/models/approve_article.rb
| ... | ... | @@ -94,7 +94,11 @@ class ApproveArticle < Task |
| 94 | 94 | end |
| 95 | 95 | |
| 96 | 96 | def target_notification_description |
| 97 | - _('%{requestor} wants to publish the article: %{article}.') % {:requestor => requestor.name, :article => article.name} | |
| 97 | + if article | |
| 98 | + _('%{requestor} wants to publish the article: %{article}.') % {:requestor => requestor.name, :article => article.name} | |
| 99 | + else | |
| 100 | + _('%{requestor} wants to publish an article that was removed.') % {:requestor => requestor.name} | |
| 101 | + end | |
| 98 | 102 | end |
| 99 | 103 | |
| 100 | 104 | def target_notification_message | ... | ... |
features/approve_article.feature
| ... | ... | @@ -11,6 +11,7 @@ Feature: approve article |
| 11 | 11 | And the following articles |
| 12 | 12 | | owner | name | body | homepage | |
| 13 | 13 | | mariasilva | Sample Article | This is an article | true | |
| 14 | + | mariasilva | Dub Wars | This is an article | false | | |
| 14 | 15 | And the following communities |
| 15 | 16 | | identifier | name | |
| 16 | 17 | | sample-community | Sample Community | |
| ... | ... | @@ -51,3 +52,21 @@ Feature: approve article |
| 51 | 52 | And I press "Apply!" |
| 52 | 53 | When I go to Sample Community's sitemap |
| 53 | 54 | Then I should not see "Sample Article" |
| 55 | + | |
| 56 | + @selenium | |
| 57 | + Scenario: reject an article that was removed | |
| 58 | + Given I am logged in as "mariasilva" | |
| 59 | + And I follow "Dub Wars" | |
| 60 | + And I follow "Spread" and wait | |
| 61 | + And I check "Sample Community" | |
| 62 | + And I press "Spread this" | |
| 63 | + And I follow "Delete" | |
| 64 | + And I press "Yes, I want." | |
| 65 | + When I am logged in as "joaosilva" | |
| 66 | + And I go to Sample Community's control panel | |
| 67 | + And I follow "Process requests" and wait | |
| 68 | + And I choose "Reject" | |
| 69 | + And I fill in "Rejection explanation" with "Article was removed." | |
| 70 | + And I press "Apply!" | |
| 71 | + Then I should see "No pending tasks" | |
| 72 | + And I should not see "You have a nil object when you didn't expect it" | ... | ... |
features/step_definitions/noosfero_steps.rb
script/sample-profiles
| ... | ... | @@ -120,3 +120,15 @@ admin = User.create!({ |
| 120 | 120 | :environment => environment, |
| 121 | 121 | }).person |
| 122 | 122 | environment.add_admin(admin) |
| 123 | + | |
| 124 | +guest = User.create!({ | |
| 125 | + :login => "guest", | |
| 126 | + :email => 'guest@localhost.localdomain', | |
| 127 | + :password => 'guest', | |
| 128 | + :password_confirmation => 'guest', | |
| 129 | + :environment => environment, | |
| 130 | +}).person | |
| 131 | +5.times do | |
| 132 | + communities.rand.add_admin(guest) | |
| 133 | + communities.rand.add_member(guest) | |
| 134 | +end | ... | ... |
test/unit/approve_article_test.rb
| ... | ... | @@ -370,6 +370,15 @@ class ApproveArticleTest < ActiveSupport::TestCase |
| 370 | 370 | assert_match(/#{task.requestor.name} wants to publish the article: #{article.name}/, email.subject) |
| 371 | 371 | end |
| 372 | 372 | |
| 373 | + should 'deliver target finished message about article deleted' do | |
| 374 | + task = ApproveArticle.new(:article => article, :target => community, :requestor => profile) | |
| 375 | + article.destroy | |
| 376 | + | |
| 377 | + email = TaskMailer.deliver_task_finished(task) | |
| 378 | + | |
| 379 | + assert_match(/#{task.requestor.name} wants to publish an article that was removed/, email.subject) | |
| 380 | + end | |
| 381 | + | |
| 373 | 382 | should 'approve an event' do |
| 374 | 383 | event = fast_create(Event, :profile_id => profile.id, :name => 'Event test', :slug => 'event-test', :abstract => 'Lead of article', :body => 'This is my event') |
| 375 | 384 | task = ApproveArticle.create!(:name => 'Event test', :article => event, :target => community, :requestor => profile) | ... | ... |