Skip to content

Commit 9984b6b

Browse files
committed
Alert org admins when an English form goes live
1 parent d3dad99 commit 9984b6b

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

app/controllers/forms/make_language_live_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ def create
2121
@make_form_live_service = MakeFormLiveService.call(current_form:, current_user:, language: params[:language])
2222
@make_form_live_service.make_language_live
2323

24+
if current_form.state_previously_changed?
25+
OrgAdminAlertsService.new(form: current_form, current_user:).form_made_live
26+
end
27+
2428
redirect_to make_language_live_show_confirmation_path
2529
end
2630

spec/requests/forms/make_language_live_controller_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,12 @@
8787
expect(FormDocument.find_by(form_id: form.id, tag: "live", language:)["content"]["live_at"]).to eq form.reload.updated_at.strftime("%Y-%m-%dT%H:%M:%S.%6NZ")
8888
end
8989

90-
it "redirects to the confirmation page" do
90+
it "sends an email to the organisation admins" do
9191
post(make_language_live_path(form_id: form.id, language:), params: form_params)
92-
expect(response).to redirect_to(make_language_live_show_confirmation_path(form_id: form.id, language:))
93-
end
92+
expect(ActionMailer::Base.deliveries.count).to eq(1)
9493

95-
it "sends an email to the organisation admins" do
96-
pending "not yet implemented"
97-
raise
94+
template_id = Settings.govuk_notify.admin_alerts.new_draft_form_made_live_template_id
95+
expect(ActionMailer::Base.deliveries.last.govuk_notify_template).to eq(template_id)
9896
end
9997
end
10098

0 commit comments

Comments
 (0)