diff options
Diffstat (limited to 'spec/models/integrations/slack_slash_commands_spec.rb')
-rw-r--r-- | spec/models/integrations/slack_slash_commands_spec.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/models/integrations/slack_slash_commands_spec.rb b/spec/models/integrations/slack_slash_commands_spec.rb new file mode 100644 index 00000000000..a9d3c820a3c --- /dev/null +++ b/spec/models/integrations/slack_slash_commands_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Integrations::SlackSlashCommands do + it_behaves_like Integrations::BaseSlashCommands + + describe '#trigger' do + context 'when an auth url is generated' do + let(:project) { create(:project) } + let(:params) do + { + team_domain: 'http://domain.tld', + team_id: 'T3423423', + user_id: 'U234234', + user_name: 'mepmep', + token: 'token' + } + end + + let(:service) do + project.create_slack_slash_commands_service( + properties: { token: 'token' }, + active: true + ) + end + + let(:authorize_url) do + 'http://authorize.example.com/' + end + + before do + allow(service).to receive(:authorize_chat_name_url).and_return(authorize_url) + end + + it 'uses slack compatible links' do + response = service.trigger(params) + + expect(response[:text]).to include("<#{authorize_url}|connect your GitLab account>") + end + end + end + + 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 +end |