Move exchanging of XMPP contacts to account confirmation
Since the ejabberd service is now being enabled after the confirmation, we also need to move the exchanging of roster contacts to that point.
This commit is contained in:
@@ -101,4 +101,52 @@ RSpec.describe User, type: :model do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#exchange_xmpp_contact_with_inviter" do
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
let(:user) { create :user, cn: "willherschel", ou: "kosmos.org" }
|
||||
let(:guest) { create :user, id: 2, cn: "isaacnewton", ou: "kosmos.org", email: "newt@example.com" }
|
||||
|
||||
before do
|
||||
Invitation.create! user: user, invited_user_id: guest.id, used_at: DateTime.now
|
||||
allow_any_instance_of(User).to receive(:services_enabled).and_return(%w[ ejabberd ])
|
||||
end
|
||||
|
||||
it "enqueues a job to exchange XMPP contacts between inviter and invitee" do
|
||||
guest.send(:exchange_xmpp_contact_with_inviter)
|
||||
|
||||
expect(enqueued_jobs.size).to eq(1)
|
||||
args = enqueued_jobs.first['arguments']
|
||||
expect(args[0]['_aj_globalid']).to match('gid://akkounts/User')
|
||||
expect(args[1]).to eq('isaacnewton')
|
||||
expect(args[2]).to eq('kosmos.org')
|
||||
end
|
||||
|
||||
after do
|
||||
clear_enqueued_jobs
|
||||
end
|
||||
end
|
||||
|
||||
describe "#devise_after_confirmation" do
|
||||
let(:user) { create :user, cn: "willherschel", ou: "kosmos.org" }
|
||||
|
||||
it "enables default services" do
|
||||
expect(user).to receive(:enable_service).with(%w[ discourse ejabberd gitea mediawiki ])
|
||||
user.send(:devise_after_confirmation)
|
||||
end
|
||||
|
||||
context "for invited user with ejabberd enabled" do
|
||||
let(:guest) { create :user, id: 2, cn: "isaacnewton", ou: "kosmos.org", email: "newt@example.com" }
|
||||
|
||||
before do
|
||||
Invitation.create! user: user, invited_user_id: guest.id, used_at: DateTime.now
|
||||
allow_any_instance_of(User).to receive(:enable_service).and_return(true)
|
||||
end
|
||||
|
||||
it "exchanges XMPP contacts with the inviter" do
|
||||
expect(guest).to receive(:exchange_xmpp_contact_with_inviter)
|
||||
guest.send(:devise_after_confirmation)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user