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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/slash_commands')
-rw-r--r--spec/lib/gitlab/slash_commands/application_help_spec.rb22
-rw-r--r--spec/lib/gitlab/slash_commands/command_spec.rb20
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/incident_management/incident_new_spec.rb15
3 files changed, 56 insertions, 1 deletions
diff --git a/spec/lib/gitlab/slash_commands/application_help_spec.rb b/spec/lib/gitlab/slash_commands/application_help_spec.rb
index b82121bf3a8..b182c0e5cc6 100644
--- a/spec/lib/gitlab/slash_commands/application_help_spec.rb
+++ b/spec/lib/gitlab/slash_commands/application_help_spec.rb
@@ -4,11 +4,13 @@ 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, params).execute
+ described_class.new(project, chat_user, params).execute
end
it 'displays the help section' do
@@ -16,5 +18,23 @@ RSpec.describe Gitlab::SlashCommands::ApplicationHelp do
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
diff --git a/spec/lib/gitlab/slash_commands/command_spec.rb b/spec/lib/gitlab/slash_commands/command_spec.rb
index 069577b3846..f4664bcfef9 100644
--- a/spec/lib/gitlab/slash_commands/command_spec.rb
+++ b/spec/lib/gitlab/slash_commands/command_spec.rb
@@ -122,5 +122,25 @@ RSpec.describe Gitlab::SlashCommands::Command do
it { is_expected.to eq(Gitlab::SlashCommands::IssueComment) }
end
+
+ context 'when incident declare is triggered' do
+ context 'IncidentNew is triggered' do
+ let(:params) { { text: 'incident declare' } }
+
+ it { is_expected.to eq(Gitlab::SlashCommands::IncidentManagement::IncidentNew) }
+ end
+
+ context 'when feature flag is disabled' do
+ before do
+ stub_feature_flags(incident_declare_slash_command: false)
+ end
+
+ context 'IncidentNew is triggered' do
+ let(:params) { { text: 'incident declare' } }
+
+ it { is_expected.not_to eq(Gitlab::SlashCommands::IncidentManagement::IncidentNew) }
+ end
+ end
+ end
end
end
diff --git a/spec/lib/gitlab/slash_commands/presenters/incident_management/incident_new_spec.rb b/spec/lib/gitlab/slash_commands/presenters/incident_management/incident_new_spec.rb
new file mode 100644
index 00000000000..cbc584b931f
--- /dev/null
+++ b/spec/lib/gitlab/slash_commands/presenters/incident_management/incident_new_spec.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::SlashCommands::Presenters::IncidentManagement::IncidentNew do
+ subject { described_class.new }
+
+ it 'returns the ephemeral message' do
+ message = subject.present('It works!')
+
+ expect(message).to be_a(Hash)
+ expect(message[:text]).to eq('It works!')
+ expect(message[:response_type]).to be(:ephemeral)
+ end
+end