Exchange XMPP contacts when invitee signs up
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
2020-12-08 19:16:08 +01:00
parent 8a0d89ef60
commit ee72a32c7e
6 changed files with 82 additions and 10 deletions

View File

@@ -1,4 +1,6 @@
require 'rails_helper'
require 'webmock/rspec'
require 'json'
RSpec.describe CreateAccount, type: :model do
let(:ldap_client_mock) { instance_double(Net::LDAP) }
@@ -68,4 +70,37 @@ RSpec.describe CreateAccount, type: :model do
service.send(:add_ldap_document)
end
end
describe "#exchange_xmpp_contacts" do
let(:inviter) { create :user, cn: "willherschel", ou: "kosmos.org" }
let(:invitation) { create :invitation, user: inviter }
let(:service) { CreateAccount.new(
username: 'isaacnewton',
email: 'isaacnewton@example.com',
password: 'bright-ideas-in-autumn',
invitation: invitation
)}
before do
stub_request(:post, "http://xmpp.example.com/api/add_rosteritem")
.to_return(status: 200, body: "", headers: {})
end
it "posts add_rosteritem commands to the ejabberd API" do
service.send(:exchange_xmpp_contacts)
expect(WebMock).to have_requested(:post, "http://xmpp.example.com/api/add_rosteritem")
.with { |req| req.body == {
localuser: "isaacnewton", localhost: "kosmos.org",
user: "willherschel", host: "kosmos.org",
nick: "willherschel", group: "Friends", subs: "both"
}}
expect(WebMock).to have_requested(:post, "http://xmpp.example.com/api/add_rosteritem")
.with { |req| req.body == {
localuser: "willherschel", localhost: "kosmos.org",
user: "isaacnewton", host: "kosmos.org",
nick: "isaacnewton", group: "Friends", subs: "both"
}}
end
end
end