summaryrefslogtreecommitdiff
path: root/spec/views/projects/clusters/clusters/gcp/_form.html.haml_spec.rb
blob: 1cb2f9a4301d2ec224968a5acfeff1b1792c8a47 (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
# frozen_string_literal: true

require 'spec_helper'

describe 'clusters/clusters/gcp/_form' do
  let(:admin) { create(:admin) }
  let(:environment) { create(:environment) }
  let(:gcp_cluster) { create(:cluster, :provided_by_gcp) }
  let(:clusterable) { ClusterablePresenter.fabricate(environment.project, current_user: admin) }

  before do
    assign(:environment, environment)
    assign(:gcp_cluster, gcp_cluster)
    allow(view).to receive(:clusterable).and_return(clusterable)
    allow(view).to receive(:url_for).and_return('#')
    allow(view).to receive(:token_in_session).and_return('')
  end

  context 'with all feature flags enabled' do
    it 'has a cloud run checkbox' do
      render

      expect(rendered).to have_selector("input[id='cluster_provider_gcp_attributes_cloud_run']")
    end
  end

  context 'with cloud run feature flag disabled' do
    before do
      stub_feature_flags(create_cloud_run_clusters: false)
    end

    it 'does not have a cloud run checkbox' do
      render

      expect(rendered).not_to have_selector("input[id='cluster_provider_gcp_attributes_cloud_run']")
    end
  end
end