Welcome to mirror list, hosted at ThFree Co, Russian Federation.

set_confidential_spec.rb « issues « mutations « graphql « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 05b787eb5ca77c7ef36af0157bb64b307a6fba08 (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
# frozen_string_literal: true

require 'spec_helper'

describe Mutations::Issues::SetConfidential do
  let(:issue) { create(:issue) }
  let(:user) { create(:user) }
  subject(:mutation) { described_class.new(object: nil, context: { current_user: user }) }

  describe '#resolve' do
    let(:confidential) { true }
    let(:mutated_issue) { subject[:issue] }
    subject { mutation.resolve(project_path: issue.project.full_path, iid: issue.iid, confidential: confidential) }

    it 'raises an error if the resource is not accessible to the user' do
      expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
    end

    context 'when the user can update the issue' do
      before do
        issue.project.add_developer(user)
      end

      it 'returns the issue as confidential' do
        expect(mutated_issue).to eq(issue)
        expect(mutated_issue.confidential).to be_truthy
        expect(subject[:errors]).to be_empty
      end

      context 'when passing confidential as false' do
        let(:confidential) { false }

        it 'updates the issue confidentiality to false' do
          expect(mutated_issue.confidential).to be_falsey
        end
      end
    end
  end
end