summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/controllers/clusters_controller_shared_examples.rb
blob: aa17e72d08e7f35285be5af76481bc838f482c8f (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 'GET new cluster shared examples' do
  describe 'EKS cluster' do
    context 'user already has an associated AWS role' do
      let!(:role) { create(:aws_role, user: user) }

      it 'does not create an Aws::Role record' do
        expect { go(provider: 'aws') }.not_to change { Aws::Role.count }

        expect(response).to have_gitlab_http_status(:ok)
        expect(assigns(:aws_role)).to eq(role)
      end
    end

    context 'user does not have an associated AWS role' do
      it 'creates an Aws::Role record' do
        expect { go(provider: 'aws') }.to change { Aws::Role.count }

        expect(response).to have_gitlab_http_status(:ok)

        role = assigns(:aws_role)
        expect(role.user).to eq(user)
        expect(role.role_arn).to be_nil
        expect(role.role_external_id).to be_present
      end
    end
  end
end