Skip to content

Commit

Permalink
notify on approved-first-post (publiclab#8421)
Browse files Browse the repository at this point in the history
* notify on approved-first-post

* Update notes_controller_test.rb
  • Loading branch information
jywarren authored and billymoroney1 committed Dec 28, 2021
1 parent 438afe3 commit f1a218d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def self.new_note(params)
img.save
end
node.save!
if node.status != 3
if node.status == 1
node.notify
end
else
Expand Down
22 changes: 14 additions & 8 deletions test/functional/notes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,9 @@ def teardown
test 'should redirect to questions show page after creating a new question' do
title = 'How to use Spectrometer'
perform_enqueued_jobs do
assert_emails 1 do
# no emails sent for first-time posters, as it's held in moderation
assert users(:bob).first_time_poster
assert_emails 0 do
user = UserSession.create(users(:bob))
post :create,
params: {
Expand All @@ -540,13 +542,17 @@ def teardown
test 'non-first-timer posts a question' do
UserSession.create(users(:jeff))
title = 'My first question to Public Lab'
post :create,
params: {
title: title,
body: 'Spectrometer question',
tags: 'question:spectrometer',
redirect: 'question'
}
perform_enqueued_jobs do
assert_emails 1 do
post :create,
params: {
title: title,
body: 'Spectrometer question',
tags: 'question:spectrometer',
redirect: 'question'
}
end
end

assert_redirected_to '/questions/' + users(:jeff).username + '/' + Time.now.strftime('%m-%d-%Y') + '/' + title.parameterize
assert_equal flash[:notice], 'Question published. In the meantime, if you have more to contribute, feel free to do so.'
Expand Down

0 comments on commit f1a218d

Please sign in to comment.