Move some Rails app services to UserManager namespace
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-23 16:03:02 +02:00
parent 90a8a70c15
commit ba683a7b95
10 changed files with 90 additions and 84 deletions
@@ -0,0 +1,40 @@
require 'rails_helper'
RSpec.describe UserManager::CreateInvitations, type: :model do
include ActiveJob::TestHelper
let(:user) { create :user }
describe "#call" do
before do
described_class.call(user: user, amount: 5)
end
after(:each) { clear_enqueued_jobs }
it "creates the right amount of invitations for the given user" do
expect(user.invitations.count).to eq(5)
end
it "sends an email notification to the user" do
expect(enqueued_jobs.size).to eq(1)
expect(enqueued_jobs.first["job_class"]).to eq("ActionMailer::MailDeliveryJob")
args = enqueued_jobs.first['arguments']
expect(args[0]).to eq("NotificationMailer")
expect(args[1]).to eq("new_invitations_available")
expect(args[3]["params"]["user"]["_aj_globalid"]).to eq("gid://akkounts/User/1")
end
end
describe "#call with notification disabled" do
before do
described_class.call(user: user, amount: 3, notify: false)
end
after(:each) { clear_enqueued_jobs }
it "does not send an email notification to the user" do
expect(enqueued_jobs.size).to eq(0)
end
end
end