summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-31 21:07:40 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-31 21:07:40 +0000
commit9e83d078577a9c066f21fcef1355f800ad895c9c (patch)
tree8995c5868449584040e58400ae2bcb9f48346fb3 /spec/lib/gitlab
parent22dde36e800253350e5fa1d902f191a7f64bc6e9 (diff)
downloadgitlab-ce-9e83d078577a9c066f21fcef1355f800ad895c9c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/chat/responder_spec.rb74
1 files changed, 57 insertions, 17 deletions
diff --git a/spec/lib/gitlab/chat/responder_spec.rb b/spec/lib/gitlab/chat/responder_spec.rb
index 803f30da9e7..a9d290cb87c 100644
--- a/spec/lib/gitlab/chat/responder_spec.rb
+++ b/spec/lib/gitlab/chat/responder_spec.rb
@@ -2,30 +2,70 @@
require 'spec_helper'
-RSpec.describe Gitlab::Chat::Responder do
+RSpec.describe Gitlab::Chat::Responder, feature_category: :integrations do
describe '.responder_for' do
- context 'using a regular build' do
- it 'returns nil' do
- build = create(:ci_build)
+ context 'when the feature flag is disabled' do
+ before do
+ stub_feature_flags(use_response_url_for_chat_responder: false)
+ end
+
+ context 'using a regular build' do
+ it 'returns nil' do
+ build = create(:ci_build)
+
+ expect(described_class.responder_for(build)).to be_nil
+ end
+ end
+
+ context 'using a chat build' do
+ it 'returns the responder for the build' do
+ pipeline = create(:ci_pipeline)
+ build = create(:ci_build, pipeline: pipeline)
+ integration = double(:integration, chat_responder: Gitlab::Chat::Responder::Slack)
+ chat_name = double(:chat_name, integration: integration)
+ chat_data = double(:chat_data, chat_name: chat_name)
+
+ allow(pipeline)
+ .to receive(:chat_data)
+ .and_return(chat_data)
- expect(described_class.responder_for(build)).to be_nil
+ expect(described_class.responder_for(build))
+ .to be_an_instance_of(Gitlab::Chat::Responder::Slack)
+ end
end
end
- context 'using a chat build' do
- it 'returns the responder for the build' do
- pipeline = create(:ci_pipeline)
- build = create(:ci_build, pipeline: pipeline)
- integration = double(:integration, chat_responder: Gitlab::Chat::Responder::Slack)
- chat_name = double(:chat_name, integration: integration)
- chat_data = double(:chat_data, chat_name: chat_name)
+ context 'when the feature flag is enabled' do
+ before do
+ stub_feature_flags(use_response_url_for_chat_responder: true)
+ end
+
+ context 'using a regular build' do
+ it 'returns nil' do
+ build = create(:ci_build)
+
+ expect(described_class.responder_for(build)).to be_nil
+ end
+ end
+
+ context 'using a chat build' do
+ let(:chat_name) { create(:chat_name, chat_id: 'U123') }
+ let(:pipeline) do
+ pipeline = create(:ci_pipeline)
+ pipeline.create_chat_data!(
+ response_url: 'https://hooks.slack.com/services/12345',
+ chat_name_id: chat_name.id
+ )
+ pipeline
+ end
- allow(pipeline)
- .to receive(:chat_data)
- .and_return(chat_data)
+ let(:build) { create(:ci_build, pipeline: pipeline) }
+ let(:responder) { described_class.new(build) }
- expect(described_class.responder_for(build))
- .to be_an_instance_of(Gitlab::Chat::Responder::Slack)
+ it 'returns the responder for the build' do
+ expect(described_class.responder_for(build))
+ .to be_an_instance_of(Gitlab::Chat::Responder::Slack)
+ end
end
end
end