Skip to content

Commit

Permalink
Update Email with notify_status
Browse files Browse the repository at this point in the history
Here we're just doing it straight off in the callback. This is probably quick enough (I suspect adding the worker infrastructure to
queue it might make it slower), but we
should confirm that.
  • Loading branch information
KludgeKML committed Nov 3, 2023
1 parent 8718bb2 commit e4ef5f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/controllers/status_updates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ def create
UnsubscribeAllService.call(subscriber, :non_existent_email) if subscriber
end

begin
Email.find(reference).update!(notify_status: status)
rescue StandardError
# At the moment we don't want to do anything if
# the reference can't be found.
end

head :no_content
end

Expand Down
12 changes: 12 additions & 0 deletions spec/integration/status_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@
expect(response.body).to eq("")
end

context "with a relevant email" do
before do
@email = create(:email, id: params[:reference])
end

it "updates the referenced email" do
post("/status-updates", params:)

expect(@email.reload.notify_status).to eq(status)
end
end

context "when a user does not have 'status_updates' permission" do
let(:permissions) { %w[signin] }

Expand Down

0 comments on commit e4ef5f2

Please sign in to comment.