Skip to content

Commit

Permalink
Merge pull request #2012 from alphagov/revert-2011-bulk_migrate_fix_task
Browse files Browse the repository at this point in the history
Revert "Temporary rake task"
  • Loading branch information
hannako authored Sep 26, 2023
2 parents 2d433c5 + 3bcf4c5 commit 65addb1
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 166 deletions.

This file was deleted.

11 changes: 0 additions & 11 deletions lib/tasks/bulk_email.rake
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,4 @@ namespace :bulk_email do
end
puts "Sending #{email_ids.count} emails to subscribers on the following lists: #{subscriber_lists.pluck(:slug).join(', ')}"
end

desc "Send a bulk email to users that were bulk unsubscribed on Friday 22nd Sept in error"
task for_users_unsubscribed_in_error: :environment do
subscriber_list = SubscriberList.find_by(slug: "intellectual-property-trade-marks")

email_ids = BulkSubscriberListEmailBuilderForFilteredSubscriptions.new(subscriber_list).call
email_ids.each do |id|
SendEmailWorker.perform_async_in_queue(id, queue: :send_email_immediate)
end
puts "Sending #{email_ids.count} emails to subscribers on subscriber list: #{subscriber_list.title}"
end
end

This file was deleted.

51 changes: 0 additions & 51 deletions spec/lib/tasks/bulk_email_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,55 +52,4 @@
).to_stdout
end
end

describe "for_users_unsubscribed_in_error" do
before do
Rake::Task["bulk_email:for_users_unsubscribed_in_error"].reenable
end

it "builds emails for a the trade marks subscriber list" do
trade_marks_subscriber_list = create(:subscriber_list, title: "Trade marks", slug: "intellectual-property-trade-marks")

expect(BulkSubscriberListEmailBuilderForFilteredSubscriptions)
.to receive(:new)
.with(trade_marks_subscriber_list)
.and_call_original

Rake::Task["bulk_email:for_users_unsubscribed_in_error"].invoke(trade_marks_subscriber_list)
end

it "enqueues the emails for delivery" do
trade_marks_subscriber_list = create(:subscriber_list, title: "Trade marks", slug: "intellectual-property-trade-marks")
builder_double = instance_double(BulkSubscriberListEmailBuilderForFilteredSubscriptions)
allow(BulkSubscriberListEmailBuilderForFilteredSubscriptions).to receive(:new).and_return(builder_double)

allow(builder_double).to receive(:call)
.and_return([1, 2])

expect(SendEmailWorker)
.to receive(:perform_async_in_queue)
.with(1, queue: :send_email_immediate)

expect(SendEmailWorker)
.to receive(:perform_async_in_queue)
.with(2, queue: :send_email_immediate)

Rake::Task["bulk_email:for_users_unsubscribed_in_error"].invoke(trade_marks_subscriber_list)
end

it "states how many emails are being sent, and to where" do
trade_marks_subscriber_list = create(:subscriber_list, title: "Trade marks", slug: "intellectual-property-trade-marks")

builder_double = instance_double(BulkSubscriberListEmailBuilderForFilteredSubscriptions)
allow(BulkSubscriberListEmailBuilderForFilteredSubscriptions).to receive(:new).and_return(builder_double)

allow(builder_double).to receive(:call)
.and_return([1, 2, 3, 4, 5])

expect { Rake::Task["bulk_email:for_users_unsubscribed_in_error"].invoke(trade_marks_subscriber_list) }
.to output(
/Sending 5 emails to subscribers on subscriber list: Trade marks/,
).to_stdout
end
end
end

0 comments on commit 65addb1

Please sign in to comment.