Refactor ejabberd API integration
This commit is contained in:
@@ -1,30 +1,17 @@
|
||||
require 'rails_helper'
|
||||
require 'webmock/rspec'
|
||||
|
||||
RSpec.describe XmppSetDefaultBookmarksJob, type: :job 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>"
|
||||
]
|
||||
end
|
||||
|
||||
subject(:job) {
|
||||
described_class.perform_later(user)
|
||||
}
|
||||
|
||||
before do
|
||||
stub_request(:post, "http://xmpp.example.com/api/private_set")
|
||||
.to_return(status: 200, body: "", headers: {})
|
||||
end
|
||||
it "calls the service for setting default bookmarks" do
|
||||
expect(EjabberdManager::SetDefaultBookmarks).to receive(:call)
|
||||
.with(user: user).and_return(true)
|
||||
|
||||
it "posts a private_set command to the ejabberd API" do
|
||||
perform_enqueued_jobs { job }
|
||||
|
||||
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
|
||||
|
||||
after do
|
||||
|
||||
Reference in New Issue
Block a user