Skip to content

Commit

Permalink
Merge dc86239 into d0f4e8d
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Apr 25, 2024
2 parents d0f4e8d + dc86239 commit 47b5cd4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/info_request.rb
Expand Up @@ -1021,7 +1021,7 @@ def set_described_state(new_state, set_by = nil, message = "")

calculate_event_states

if requires_admin?
if old_described_state != described_state && requires_admin?
# Check there is someone to send the message "from"
if set_by && user
RequestMailer.requires_admin(self, set_by, message).deliver_now
Expand Down
1 change: 1 addition & 0 deletions doc/CHANGES.md
Expand Up @@ -2,6 +2,7 @@

## Highlighted Features

* Prevent multiple require admin emails from being sent (Graeme Porteous)
* Add default value and not null constraint to `CensorRule#regexp` (Gareth Rees)
* Allow requests to be listed and filtered by tag (Graeme Porteous)
* Fix admin error when authority are missing an email address (Graeme Porteous)
Expand Down
28 changes: 28 additions & 0 deletions spec/models/info_request_spec.rb
Expand Up @@ -3495,6 +3495,34 @@ def create_old_unclassified_holding_pen
expect(events[1].calculated_state).to eq("gone_postal")
end
end

context "a series of require admin events on a request" do
before { ActionMailer::Base.deliveries.clear }

it "does not send multiple require admin reports" do
# Request sent to old/invalid address
request.log_event('sent', {})
request.set_described_state('waiting_response')

# A bounce is received
request.awaiting_description = true
request.log_event('response', {})

# Requester classifies as error_message
request.log_event('status_update', {})
expect { request.set_described_state('error_message', request.user) }.
to change { ActionMailer::Base.deliveries.size }.by(1)

# A second bounce is received
request.awaiting_description = true
request.log_event('response', {})

# Requester classifies as error_message again
request.log_event('status_update', {})
expect { request.set_described_state('error_message', request.user) }.
to_not change { ActionMailer::Base.deliveries.size }
end
end
end
end

Expand Down

0 comments on commit 47b5cd4

Please sign in to comment.