BigW Consortium Gitlab

slack_slash_commands_service_spec.rb 999 Bytes
Newer Older
1 2
require 'spec_helper'

3
describe SlackSlashCommandsService do
4
  it_behaves_like "chat slash commands service"
5 6 7

  describe '#trigger' do
    context 'when an auth url is generated' do
8
      let(:project) { create(:project) }
9 10 11 12 13 14 15 16 17
      let(:params) do
        {
          team_domain: 'http://domain.tld',
          team_id: 'T3423423',
          user_id: 'U234234',
          user_name: 'mepmep',
          token: 'token'
        }
      end
18

19 20
      let(:service) do
        project.create_slack_slash_commands_service(
21 22
          properties: { token: 'token' },
          active: true
23 24
        )
      end
25

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
      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
41
end