2019-03-30 03:23:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-16 08:21:06 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-06-03 05:10:18 -04:00
|
|
|
RSpec.describe Integrations::SlackSlashCommands do
|
|
|
|
it_behaves_like Integrations::BaseSlashCommands
|
2016-12-16 09:08:10 -05:00
|
|
|
|
|
|
|
describe '#trigger' do
|
|
|
|
context 'when an auth url is generated' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2016-12-16 09:08:10 -05:00
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
team_domain: 'http://domain.tld',
|
|
|
|
team_id: 'T3423423',
|
|
|
|
user_id: 'U234234',
|
|
|
|
user_name: 'mepmep',
|
|
|
|
token: 'token'
|
|
|
|
}
|
|
|
|
end
|
2016-12-19 09:40:06 -05:00
|
|
|
|
2021-06-30 20:08:17 -04:00
|
|
|
let(:integration) do
|
2021-06-18 11:10:16 -04:00
|
|
|
project.create_slack_slash_commands_integration(
|
2016-12-22 04:54:35 -05:00
|
|
|
properties: { token: 'token' },
|
|
|
|
active: true
|
2016-12-16 09:08:10 -05:00
|
|
|
)
|
|
|
|
end
|
2016-12-19 09:40:06 -05:00
|
|
|
|
2016-12-16 09:08:10 -05:00
|
|
|
let(:authorize_url) do
|
|
|
|
'http://authorize.example.com/'
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
2021-06-30 20:08:17 -04:00
|
|
|
allow(integration).to receive(:authorize_chat_name_url).and_return(authorize_url)
|
2016-12-16 09:08:10 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'uses slack compatible links' do
|
2021-06-30 20:08:17 -04:00
|
|
|
response = integration.trigger(params)
|
2016-12-16 09:08:10 -05:00
|
|
|
|
|
|
|
expect(response[:text]).to include("<#{authorize_url}|connect your GitLab account>")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-02-20 16:29:48 -05:00
|
|
|
|
|
|
|
describe '#chat_responder' do
|
|
|
|
it 'returns the responder to use for Slack' do
|
|
|
|
expect(described_class.new.chat_responder)
|
|
|
|
.to eq(Gitlab::Chat::Responder::Slack)
|
|
|
|
end
|
|
|
|
end
|
2016-12-16 08:21:06 -05:00
|
|
|
end
|