blob: 3a775e8f101e09b5fa23ab2ab6243e7c109dad97 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::SlashCommands::Presenters::Run do
let(:presenter) { described_class.new }
describe '#present' do
context 'when no builds are present' do
it 'returns an error' do
builds = double(:builds, take: nil)
pipeline = double(:pipeline, builds: builds)
expect(presenter)
.to receive(:unsupported_chat_service)
presenter.present(pipeline)
end
end
context 'when a responder could be found' do
it 'returns the output for a scheduled pipeline' do
responder = double(:responder, scheduled_output: 'hello')
build = double(:build)
builds = double(:builds, take: build)
pipeline = double(:pipeline, builds: builds)
allow(Gitlab::Chat::Responder)
.to receive(:responder_for)
.with(build)
.and_return(responder)
expect(presenter)
.to receive(:in_channel_response)
.with('hello')
presenter.present(pipeline)
end
end
context 'when a responder could not be found' do
it 'returns an error' do
build = double(:build)
builds = double(:builds, take: build)
pipeline = double(:pipeline, builds: builds)
allow(Gitlab::Chat::Responder)
.to receive(:responder_for)
.with(build)
.and_return(nil)
expect(presenter)
.to receive(:unsupported_chat_service)
presenter.present(pipeline)
end
end
end
describe '#unsupported_chat_service' do
it 'returns an ephemeral response' do
expect(presenter)
.to receive(:ephemeral_response)
.with(text: /Sorry, this chat service is currently not supported/)
presenter.unsupported_chat_service
end
end
describe '#failed_to_schedule' do
it 'returns an ephemeral response' do
expect(presenter)
.to receive(:ephemeral_response)
.with(text: /The command could not be scheduled/)
presenter.failed_to_schedule('foo')
end
end
end
|