Skip to content

Commit 07bef94

Browse files
Merge pull request #2375 from alphagov/fix-prompt-for-email-alerts-rake
[WHIT-1876] Fix prompt for email alerts rake
2 parents 64e7930 + b4cf193 commit 07bef94

3 files changed

Lines changed: 9 additions & 27 deletions

File tree

lib/tasks/email_alerts.rake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ namespace :email_alerts do
1010
abort "Please provide an edition ID, e.g. rake #{task.name}[fedc13e231ccd7d63e1abf65]" unless args[:edition_id]
1111

1212
edition = TravelAdviceEdition.find(args[:edition_id])
13-
puts "Sending an email alert for #{edition.title}"
14-
unless shell.yes?("Proceed with sending this email alert? (yes/no)")
15-
shell.say_error "Aborted"
13+
unless shell.yes?("Proceed with sending an email alert for #{edition.title}? (yes/no)")
14+
shell.say "Aborted"
1615
next
1716
end
1817
EmailAlertApiNotifier.send_alert(edition)

lib/tasks/publishing_api.rake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace :publishing_api do
1010
presenter = IndexPresenter.new
1111

1212
unless shell.yes?("You are about to publish travel advice index content item. Would you like to proceed? (yes/no)")
13-
shell.say_error("Aborted")
13+
shell.say "Aborted"
1414
next
1515
end
1616
GdsApi.publishing_api.put_content(presenter.content_id, presenter.render_for_publishing_api)
@@ -24,7 +24,7 @@ namespace :publishing_api do
2424
alternative_path = "/foreign-travel-advice/#{args[:new_country_slug]}"
2525

2626
unless shell.yes?("You are about to unpublish a published travel advice page and email signup page for #{country} and redirect to #{alternative_path}")
27-
shell.say_error("Aborted")
27+
shell.say "Aborted"
2828
next
2929
end
3030
GdsApi.publishing_api.unpublish(country.email_signup_content_id, type: "redirect", alternative_path: "#{alternative_path}/email-signup")
@@ -42,7 +42,7 @@ namespace :publishing_api do
4242
desc "republish all published editions to publishing-api"
4343
task republish_editions: :environment do
4444
unless shell.yes?("You are about to republish all travel advice content items. Would you like to proceed? (yes/no)")
45-
shell.say_error("Aborted")
45+
shell.say "Aborted"
4646
next
4747
end
4848
TravelAdviceEdition.published.each do |edition|
@@ -86,7 +86,7 @@ namespace :publishing_api do
8686
desc "republish a published edition to publishing-api for a country"
8787
task :republish_edition, [:country_slug] => :environment do |_task, args|
8888
unless shell.yes?("You are about to republish published travel advice for #{args[:country_slug]}. Would you like to proceed? (yes/no)")
89-
shell.say_error("Aborted")
89+
shell.say "Aborted"
9090
next
9191
end
9292
edition = TravelAdviceEdition.published.find_by(country_slug: args[:country_slug])
@@ -113,7 +113,7 @@ namespace :publishing_api do
113113
presenter = EmailAlertSignup::IndexPresenter.new
114114

115115
unless shell.yes?("You are about to republish email sign up pages for travel advice index. Would you like to proceed? (yes/no)")
116-
shell.say_error("Aborted")
116+
shell.say "Aborted"
117117
next
118118
end
119119
GdsApi.publishing_api.put_content(presenter.content_id, presenter.content_payload)
@@ -123,7 +123,7 @@ namespace :publishing_api do
123123
desc "republish email signup content item for all countries"
124124
task editions: :environment do
125125
unless shell.yes?("You are about to republish email signup pages for all countries. Would you like to proceed? (yes/no)")
126-
shell.say_error("Aborted")
126+
shell.say "Aborted"
127127
next
128128
end
129129
TravelAdviceEdition.published.each do |edition|
@@ -144,7 +144,7 @@ namespace :publishing_api do
144144
presenter = EmailAlertSignup::EditionPresenter.new(edition)
145145

146146
unless shell.yes?("You are about to republish email signup for #{args[:country_slug]}. Would you like to proceed? (yes/no)")
147-
shell.say_error("Aborted")
147+
shell.say "Aborted"
148148
next
149149
end
150150
GdsApi.publishing_api.put_content(presenter.content_id, presenter.content_payload)

spec/tasks/publishing_api_rake_spec.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@
4949
),
5050
)
5151
end
52-
53-
it "aborts when the user declines the confirmation prompt" do
54-
allow_any_instance_of(Thor::Shell::Basic).to receive(:yes?).and_return(false)
55-
56-
expect_any_instance_of(Thor::Shell::Basic).to receive(:say_error).with("Aborted")
57-
task.invoke
58-
end
5952
end
6053

6154
describe "republish_edition" do
@@ -91,11 +84,6 @@
9184
expect(a_request(:post, GdsApi::TestHelpers::PublishingApi::PUBLISHING_API_V2_ENDPOINT + "/content/#{country.content_id}/publish"))
9285
.not_to have_been_made
9386
end
94-
it "aborts when the user declines the confirmation prompt." do
95-
allow_any_instance_of(Thor::Shell::Basic).to receive(:yes?).and_return(false)
96-
expect_any_instance_of(Thor::Shell::Basic).to receive(:say_error).with("Aborted")
97-
task.invoke(country.slug)
98-
end
9987
end
10088

10189
describe "republish_editions" do
@@ -157,10 +145,5 @@
157145

158146
assert_publishing_api_publish("b5c8e64b-3461-4447-9144-1588e4a84fe6", "update_type" => "republish")
159147
end
160-
it "aborts when the user declines the confirmation prompt." do
161-
allow_any_instance_of(Thor::Shell::Basic).to receive(:yes?).and_return(false)
162-
expect_any_instance_of(Thor::Shell::Basic).to receive(:say_error).with("Aborted")
163-
task.invoke
164-
end
165148
end
166149
end

0 commit comments

Comments
 (0)