summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/slash_commands/presenters/deploy_spec.rb
blob: dee3c77db2760ca871c632e490857d506a6308d6 (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
require 'spec_helper'

describe Gitlab::SlashCommands::Presenters::Deploy do
  let(:build) { create(:ci_build) }

  describe '#present' do
    subject { described_class.new(build).present('staging', 'prod') }

    it { is_expected.to have_key(:text) }
    it { is_expected.to have_key(:response_type) }
    it { is_expected.to have_key(:status) }
    it { is_expected.not_to have_key(:attachments) }

    it 'messages the channel of the deploy' do
      expect(subject[:response_type]).to be(:in_channel)
      expect(subject[:text]).to start_with("Deployment started from staging to prod")
    end
  end

  describe '#no_actions' do
    subject { described_class.new(nil).no_actions }

    it { is_expected.to have_key(:text) }
    it { is_expected.to have_key(:response_type) }
    it { is_expected.to have_key(:status) }
    it { is_expected.not_to have_key(:attachments) }

    it 'tells the user there is no action' do
      expect(subject[:response_type]).to be(:ephemeral)
      expect(subject[:text]).to eq("No action found to be executed")
    end
  end

  describe '#too_many_actions' do
    subject { described_class.new([]).too_many_actions }

    it { is_expected.to have_key(:text) }
    it { is_expected.to have_key(:response_type) }
    it { is_expected.to have_key(:status) }
    it { is_expected.not_to have_key(:attachments) }

    it 'tells the user there is no action' do
      expect(subject[:response_type]).to be(:ephemeral)
      expect(subject[:text]).to eq("Too many actions defined")
    end
  end
end