2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Gitlab::Chat::Responder do
|
2019-07-07 11:18:12 +05:30
|
|
|
describe '.responder_for' do
|
|
|
|
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)
|
2021-06-08 01:23:25 +05:30
|
|
|
integration = double(:integration, chat_responder: Gitlab::Chat::Responder::Slack)
|
|
|
|
chat_name = double(:chat_name, integration: integration)
|
2019-07-07 11:18:12 +05:30
|
|
|
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_an_instance_of(Gitlab::Chat::Responder::Slack)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|