aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2012-08-22 11:23:23 +0100
committerLouise Crow <louise.crow@gmail.com>2012-08-22 11:23:23 +0100
commit829a9af526cecaa53c8810ceb83af26a4f30f238 (patch)
tree6b5493ebbbf746a23944d80aac9360c6412e4963
parent744548b8943f38e56a8021fa16c3c00ef11c1356 (diff)
Don't send comment alerts for external requests.
-rw-r--r--app/models/request_mailer.rb7
-rw-r--r--spec/controllers/request_controller_spec.rb10
2 files changed, 14 insertions, 3 deletions
diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb
index 03d26f237..ba9285fc6 100644
--- a/app/models/request_mailer.rb
+++ b/app/models/request_mailer.rb
@@ -28,17 +28,17 @@ class RequestMailer < ApplicationMailer
:filename => attachment_name
end
end
-
+
# Used when a response is uploaded using the API
def external_response(info_request, body, sent_at, attachments)
@from = blackhole_email
@recipients = info_request.incoming_name_and_email
@body = { :body => body }
-
+
# ActionMailer only works properly when the time is in the local timezone:
# see https://rails.lighthouseapp.com/projects/8994/tickets/3113-actionmailer-only-works-correctly-with-sent_on-times-that-are-in-the-local-time-zone
@sent_on = sent_at.dup.localtime
-
+
attachments.each do |attachment_hash|
attachment attachment_hash
end
@@ -392,6 +392,7 @@ class RequestMailer < ApplicationMailer
)
for info_request in info_requests
+ next if info_request.is_external?
# Count number of new comments to alert on
earliest_unalerted_comment_event = nil
last_comment_event = nil
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 92fde2522..dc970bf5f 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1639,6 +1639,16 @@ describe RequestController, "comment alerts" do
deliveries.size.should == 0
end
+ it 'should not send an alert for a comment on an external request' do
+ external_request = info_requests(:external_request)
+ external_request.add_comment("This external request is interesting", users(:silly_name_user))
+ # try to send comment alert
+ RequestMailer.alert_comment_on_request
+
+ deliveries = ActionMailer::Base.deliveries
+ deliveries.size.should == 0
+ end
+
it "should send an alert when there are two new comments" do
# add two comments - the second one sould be ignored, as is by the user who made the request.
# the new comment here, will cause the one in the fixture to be picked up as a new comment by alert_comment_on_request also.