mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
@@ -35,7 +35,7 @@ module Admin
|
||||
new_user.save!
|
||||
|
||||
@enterprise.users << new_user
|
||||
ManagerInvitationJob.perform_later(@enterprise.id, new_user.id)
|
||||
EnterpriseMailer.manager_invitation(@enterprise, new_user).deliver_later
|
||||
|
||||
new_user
|
||||
end
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ConfirmSignupJob < ActiveJob::Base
|
||||
def perform(user_id)
|
||||
user = Spree::User.find user_id
|
||||
Spree::UserMailer.signup_confirmation(user).deliver_now
|
||||
end
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ManagerInvitationJob < ActiveJob::Base
|
||||
def perform(enterprise_id, user_id)
|
||||
enterprise = Enterprise.find enterprise_id
|
||||
user = Spree::User.find user_id
|
||||
EnterpriseMailer.manager_invitation(enterprise, user).deliver_now
|
||||
end
|
||||
end
|
||||
@@ -1,8 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WelcomeEnterpriseJob < ActiveJob::Base
|
||||
def perform(enterprise_id)
|
||||
enterprise = Enterprise.find enterprise_id
|
||||
EnterpriseMailer.welcome(enterprise).deliver_now
|
||||
end
|
||||
end
|
||||
@@ -400,7 +400,7 @@ class Enterprise < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def send_welcome_email
|
||||
WelcomeEnterpriseJob.perform_later(id)
|
||||
EnterpriseMailer.welcome(self).deliver_later
|
||||
end
|
||||
|
||||
def strip_url(url)
|
||||
|
||||
@@ -101,7 +101,7 @@ module Spree
|
||||
end
|
||||
|
||||
def send_signup_confirmation
|
||||
ConfirmSignupJob.perform_later(id)
|
||||
Spree::UserMailer.signup_confirmation(self).deliver_later
|
||||
end
|
||||
|
||||
def associate_customers
|
||||
|
||||
@@ -28,16 +28,17 @@ module Admin
|
||||
end
|
||||
|
||||
context "signing up a new user" do
|
||||
let(:manager_invitation) { instance_double(ManagerInvitationJob) }
|
||||
let(:mail_mock) { double(:mailer, deliver_later: true) }
|
||||
|
||||
before do
|
||||
setup_email
|
||||
allow(EnterpriseMailer).to receive(:manager_invitation).
|
||||
with(enterprise, kind_of(Spree::User)) { mail_mock }
|
||||
|
||||
allow(controller).to receive_messages spree_current_user: admin
|
||||
end
|
||||
|
||||
it 'enqueues an invitation email' do
|
||||
expect(ManagerInvitationJob)
|
||||
.to receive(:perform_later).with(enterprise.id, kind_of(Integer))
|
||||
expect(mail_mock).to receive(:deliver_later)
|
||||
|
||||
spree_post :create, email: 'un.registered@email.com', enterprise_id: enterprise.id
|
||||
end
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe ConfirmSignupJob do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
it "sends a confirmation email to the user" do
|
||||
mail = double(:mail)
|
||||
expect(Spree::UserMailer).to receive(:signup_confirmation).with(user).and_return(mail)
|
||||
expect(mail).to receive(:deliver_now)
|
||||
|
||||
ConfirmSignupJob.perform_now(user.id)
|
||||
end
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe WelcomeEnterpriseJob do
|
||||
let(:enterprise) { create(:enterprise) }
|
||||
|
||||
it "sends a welcome email to the enterprise" do
|
||||
mail = double(:mail)
|
||||
expect(EnterpriseMailer).to receive(:welcome).with(enterprise).and_return(mail)
|
||||
expect(mail).to receive(:deliver_now)
|
||||
|
||||
WelcomeEnterpriseJob.perform_now(enterprise.id)
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,9 @@ describe Enterprise do
|
||||
it "sends a welcome email" do
|
||||
expect do
|
||||
create(:enterprise, owner: user)
|
||||
end.to enqueue_job WelcomeEnterpriseJob
|
||||
end.to enqueue_job ActionMailer::DeliveryJob
|
||||
|
||||
expect(enqueued_jobs.last.to_s).to match "welcome"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -111,7 +111,9 @@ describe Spree::User do
|
||||
|
||||
expect do
|
||||
create(:user, confirmed_at: nil).confirm
|
||||
end.to enqueue_job ConfirmSignupJob
|
||||
end.to enqueue_job ActionMailer::DeliveryJob
|
||||
|
||||
expect(enqueued_jobs.last.to_s).to match "signup_confirmation"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user