Refactor ejabberd API integration
This commit is contained in:
22
spec/services/ejabberd_manager/set_default_bookmarks_spec.rb
Normal file
22
spec/services/ejabberd_manager/set_default_bookmarks_spec.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
require 'rails_helper'
|
||||
require 'webmock/rspec'
|
||||
|
||||
RSpec.describe EjabberdManager::SetDefaultBookmarks, type: :model do
|
||||
let(:user) { create :user, cn: "willherschel", ou: "kosmos.org" }
|
||||
|
||||
before do
|
||||
Setting.xmpp_default_rooms = [
|
||||
"Welcome <welcome@kosmos.chat>",
|
||||
"Kosmos Dev <kosmos-dev@kosmos.chat>"
|
||||
]
|
||||
stub_request(:post, "http://xmpp.example.com/api/private_set")
|
||||
.to_return(status: 200, body: "", headers: {})
|
||||
|
||||
described_class.call(user:)
|
||||
end
|
||||
|
||||
it "posts a private_set command to the ejabberd API" do
|
||||
expect(WebMock).to have_requested(:post, "http://xmpp.example.com/api/private_set")
|
||||
.with { |req| req.body == '{"user":"willherschel","host":"kosmos.org","element":"\u003cstorage xmlns=\'storage:bookmarks\'\u003e\u003cconference jid=\'welcome@kosmos.chat\' name=\'Welcome\' autojoin=\'false\'\u003e\u003cnick\u003ewillherschel\u003c/nick\u003e\u003c/conference\u003e\u003cconference jid=\'kosmos-dev@kosmos.chat\' name=\'Kosmos Dev\' autojoin=\'false\'\u003e\u003cnick\u003ewillherschel\u003c/nick\u003e\u003c/conference\u003e\u003c/storage\u003e"}' }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user