summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/slash_commands/application_help_spec.rb
blob: b182c0e5cc6c7aa89fa33172dbec8ffeb143fd07 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::SlashCommands::ApplicationHelp do
  let(:params) { { command: '/gitlab', text: 'help' } }
  let_it_be(:user) { create(:user) }
  let_it_be(:chat_user) { create(:chat_name, user: user) }
  let(:project) { build(:project) }

  describe '#execute' do
    subject do
      described_class.new(project, chat_user, params).execute
    end

    it 'displays the help section' do
      expect(subject[:response_type]).to be(:ephemeral)
      expect(subject[:text]).to include('Available commands')
      expect(subject[:text]).to include('/gitlab [project name or alias] issue show')
    end

    context 'with incident declare command' do
      context 'when feature flag is enabled' do
        it 'displays the declare command' do
          expect(subject[:text]).to include('/gitlab incident declare')
        end
      end

      context 'when feature flag is disabled' do
        before do
          stub_feature_flags(incident_declare_slash_command: false)
        end

        it 'does not displays the declare command' do
          expect(subject[:text]).not_to include('/gitlab incident declare')
        end
      end
    end
  end
end