Welcome to mirror list, hosted at ThFree Co, Russian Federation.

slack_slash_commands_spec.rb « integrations « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5d6f214a5d5814324255fb7d139ed9e4610f51b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Integrations::SlackSlashCommands, feature_category: :integrations do
  it_behaves_like Integrations::BaseSlashCommands

  describe '#trigger' do
    context 'when an auth url is generated' do
      let_it_be(:project) { create(:project) }
      let(:params) do
        {
          team_domain: 'http://domain.tld',
          team_id: 'T3423423',
          user_id: 'U234234',
          user_name: 'mepmep',
          token: 'token'
        }
      end

      let(:integration) do
        project.create_slack_slash_commands_integration(
          properties: { token: 'token' },
          active: true
        )
      end

      let(:authorize_url) do
        'http://authorize.example.com/'
      end

      before do
        allow(integration).to receive(:authorize_chat_name_url).and_return(authorize_url)
      end

      it 'uses slack compatible links' do
        response = integration.trigger(params)

        expect(response[:text]).to include("<#{authorize_url}|connect your GitLab account>")
      end
    end
  end

  describe '#redirect_url' do
    let(:integration) { build(:slack_slash_commands_integration) }

    subject { integration.redirect_url('team', 'channel', 'www.example.com') }

    it { is_expected.to eq('slack://channel?team=team&id=channel') }
  end

  describe '#confirmation_url' do
    let(:integration) { build(:slack_slash_commands_integration) }
    let(:params) do
      {
        team_id: 'T123456',
        channel_id: 'C654321',
        response_url: 'https://hooks.slack.com/services/T123456/C654321'
      }
    end

    subject { integration.confirmation_url('command-id', params) }

    it { is_expected.to be_present }
  end
end