Exchange XMPP contacts when invitee signs up
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user