summaryrefslogtreecommitdiff
path: root/spec/requests/api/graphql/terraform/state/lock_spec.rb
blob: e4d3b6336aba23cc910e42dc6df0cac240f3ff8d (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'lock a terraform state' do
  include GraphqlHelpers

  let_it_be(:project) { create(:project) }
  let_it_be(:user) { create(:user, maintainer_projects: [project]) }

  let(:state) { create(:terraform_state, project: project) }
  let(:mutation) { graphql_mutation(:terraform_state_lock, id: state.to_global_id.to_s) }

  before do
    expect(state).not_to be_locked
    post_graphql_mutation(mutation, current_user: user)
  end

  include_examples 'a working graphql query'

  it 'locks the state' do
    expect(state.reload).to be_locked
    expect(state.locked_by_user).to eq(user)
  end
end