|
|
|
@ -4,23 +4,22 @@ require "rake"
|
|
|
|
|
describe "rake onboarding_emails:send", type: task do |
|
|
|
|
subject(:task) { Rake::Task["onboarding_emails:send"] } |
|
|
|
|
|
|
|
|
|
let!(:user) { FactoryBot.create(:user) } |
|
|
|
|
let(:notify_client) { instance_double(Notifications::Client) } |
|
|
|
|
let(:devise_notify_mailer) { DeviseNotifyMailer.new } |
|
|
|
|
let(:reset_password_token) { "MCDH5y6Km-U7CFPgAMVS" } |
|
|
|
|
context "when onboarding a new organisation to private beta" do |
|
|
|
|
let!(:user) { FactoryBot.create(:user) } |
|
|
|
|
let(:notify_client) { instance_double(Notifications::Client) } |
|
|
|
|
let(:devise_notify_mailer) { DeviseNotifyMailer.new } |
|
|
|
|
let(:reset_password_token) { "MCDH5y6Km-U7CFPgAMVS" } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
Rake.application.rake_require("tasks/onboarding_emails") |
|
|
|
|
Rake::Task.define_task(:environment) |
|
|
|
|
task.reenable |
|
|
|
|
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer) |
|
|
|
|
allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client) |
|
|
|
|
allow(notify_client).to receive(:send_email).and_return(true) |
|
|
|
|
allow(Devise.token_generator).to receive(:generate).and_return(reset_password_token) |
|
|
|
|
allow(user).to receive(:host).and_return("http://localhost:3000") |
|
|
|
|
end |
|
|
|
|
before do |
|
|
|
|
Rake.application.rake_require("tasks/onboarding_emails") |
|
|
|
|
Rake::Task.define_task(:environment) |
|
|
|
|
task.reenable |
|
|
|
|
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer) |
|
|
|
|
allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client) |
|
|
|
|
allow(notify_client).to receive(:send_email).and_return(true) |
|
|
|
|
allow(Devise.token_generator).to receive(:generate).and_return(reset_password_token) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when onboarding a new organisation to private beta" do |
|
|
|
|
it "can send the onboarding emails" do |
|
|
|
|
expect(notify_client).to receive(:send_email).with( |
|
|
|
|
{ |
|
|
|
@ -33,7 +32,7 @@ describe "rake onboarding_emails:send", type: task do
|
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
task.invoke(user.organisation.id) |
|
|
|
|
task.invoke(user.organisation.id, "http://localhost:3000") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|