Commit 54b794567af89d89c1879f341969e43ff242e581
1 parent
b052d280
Exists in
master
and in
29 other branches
Check if article exists before trying to get its name
- fix a litle bug in a cucumber step to create articles - adding 'guest' user via sample data scripts (ActionItem2054)
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,7 +94,11 @@ class ApproveArticle < Task | ||
94 | end | 94 | end |
95 | 95 | ||
96 | def target_notification_description | 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 | end | 102 | end |
99 | 103 | ||
100 | def target_notification_message | 104 | def target_notification_message |
features/approve_article.feature
@@ -11,6 +11,7 @@ Feature: approve article | @@ -11,6 +11,7 @@ Feature: approve article | ||
11 | And the following articles | 11 | And the following articles |
12 | | owner | name | body | homepage | | 12 | | owner | name | body | homepage | |
13 | | mariasilva | Sample Article | This is an article | true | | 13 | | mariasilva | Sample Article | This is an article | true | |
14 | + | mariasilva | Dub Wars | This is an article | false | | ||
14 | And the following communities | 15 | And the following communities |
15 | | identifier | name | | 16 | | identifier | name | |
16 | | sample-community | Sample Community | | 17 | | sample-community | Sample Community | |
@@ -51,3 +52,21 @@ Feature: approve article | @@ -51,3 +52,21 @@ Feature: approve article | ||
51 | And I press "Apply!" | 52 | And I press "Apply!" |
52 | When I go to Sample Community's sitemap | 53 | When I go to Sample Community's sitemap |
53 | Then I should not see "Sample Article" | 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
@@ -65,7 +65,7 @@ Given /^the following (articles|events|blogs|folders|forums|galleries)$/ do |con | @@ -65,7 +65,7 @@ Given /^the following (articles|events|blogs|folders|forums|galleries)$/ do |con | ||
65 | result.parent = Article.find_by_name(parent) | 65 | result.parent = Article.find_by_name(parent) |
66 | end | 66 | end |
67 | result.save! | 67 | result.save! |
68 | - if home | 68 | + if home == 'true' |
69 | owner.home_page = result | 69 | owner.home_page = result |
70 | owner.save! | 70 | owner.save! |
71 | end | 71 | end |
script/sample-profiles
@@ -120,3 +120,15 @@ admin = User.create!({ | @@ -120,3 +120,15 @@ admin = User.create!({ | ||
120 | :environment => environment, | 120 | :environment => environment, |
121 | }).person | 121 | }).person |
122 | environment.add_admin(admin) | 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,6 +370,15 @@ class ApproveArticleTest < ActiveSupport::TestCase | ||
370 | assert_match(/#{task.requestor.name} wants to publish the article: #{article.name}/, email.subject) | 370 | assert_match(/#{task.requestor.name} wants to publish the article: #{article.name}/, email.subject) |
371 | end | 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 | should 'approve an event' do | 382 | should 'approve an event' do |
374 | event = fast_create(Event, :profile_id => profile.id, :name => 'Event test', :slug => 'event-test', :abstract => 'Lead of article', :body => 'This is my event') | 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 | task = ApproveArticle.create!(:name => 'Event test', :article => event, :target => community, :requestor => profile) | 384 | task = ApproveArticle.create!(:name => 'Event test', :article => event, :target => community, :requestor => profile) |