summaryrefslogtreecommitdiff
path: root/spec/models/integrations/mattermost_slash_commands_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/integrations/mattermost_slash_commands_spec.rb')
-rw-r--r--spec/models/integrations/mattermost_slash_commands_spec.rb30
1 files changed, 16 insertions, 14 deletions
diff --git a/spec/models/integrations/mattermost_slash_commands_spec.rb b/spec/models/integrations/mattermost_slash_commands_spec.rb
index c8a6584591c..b6abe00469b 100644
--- a/spec/models/integrations/mattermost_slash_commands_spec.rb
+++ b/spec/models/integrations/mattermost_slash_commands_spec.rb
@@ -5,27 +5,29 @@ require 'spec_helper'
RSpec.describe Integrations::MattermostSlashCommands do
it_behaves_like Integrations::BaseSlashCommands
- context 'Mattermost API' do
+ describe 'Mattermost API' do
let(:project) { create(:project) }
- let(:service) { project.build_mattermost_slash_commands_service }
+ let(:integration) { project.build_mattermost_slash_commands_integration }
let(:user) { create(:user) }
before do
session = ::Mattermost::Session.new(nil)
session.base_uri = 'http://mattermost.example.com'
- allow_any_instance_of(::Mattermost::Client).to receive(:with_session)
- .and_yield(session)
+ allow(session).to receive(:with_session).and_yield(session)
+ allow(::Mattermost::Session).to receive(:new).and_return(session)
end
describe '#configure' do
subject do
- service.configure(user, team_id: 'abc',
- trigger: 'gitlab', url: 'http://trigger.url',
- icon_url: 'http://icon.url/icon.png')
+ integration.configure(user,
+ team_id: 'abc',
+ trigger: 'gitlab',
+ url: 'http://trigger.url',
+ icon_url: 'http://icon.url/icon.png')
end
- context 'the requests succeeds' do
+ context 'when the request succeeds' do
before do
stub_request(:post, 'http://mattermost.example.com/api/v4/commands')
.with(body: {
@@ -48,18 +50,18 @@ RSpec.describe Integrations::MattermostSlashCommands do
)
end
- it 'saves the service' do
+ it 'saves the integration' do
expect { subject }.to change { project.integrations.count }.by(1)
end
it 'saves the token' do
subject
- expect(service.reload.token).to eq('token')
+ expect(integration.reload.token).to eq('token')
end
end
- context 'an error is received' do
+ context 'when an error is received' do
before do
stub_request(:post, 'http://mattermost.example.com/api/v4/commands')
.to_return(
@@ -86,10 +88,10 @@ RSpec.describe Integrations::MattermostSlashCommands do
describe '#list_teams' do
subject do
- service.list_teams(user)
+ integration.list_teams(user)
end
- context 'the requests succeeds' do
+ context 'when the request succeeds' do
before do
stub_request(:get, 'http://mattermost.example.com/api/v4/users/me/teams')
.to_return(
@@ -104,7 +106,7 @@ RSpec.describe Integrations::MattermostSlashCommands do
end
end
- context 'an error is received' do
+ context 'when an error is received' do
before do
stub_request(:get, 'http://mattermost.example.com/api/v4/users/me/teams')
.to_return(