summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/lib/api/terraform_state_enabled_shared_examples.rb
blob: b88eade7db22b218e096648cccae0a5bcdc73a79 (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
# frozen_string_literal: true

RSpec.shared_examples 'it depends on value of the `terraform_state.enabled` config' do |params = {}|
  let(:expected_success_status) { params[:success_status] || :ok }

  context 'when terraform_state.enabled=false' do
    before do
      stub_config(terraform_state: { enabled: false })
    end

    it 'returns `forbidden` response' do
      request

      expect(response).to have_gitlab_http_status(:forbidden)
    end
  end

  context 'when terraform_state.enabled=true' do
    before do
      stub_config(terraform_state: { enabled: true })
    end

    it 'returns a successful response' do
      request

      expect(response).to have_gitlab_http_status(expected_success_status)
    end
  end
end