blob: 495b8442d95ebb188a8fd608036c747663ae5527 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Mutations::Issues::SetConfidential do
let(:project) { create(:project, :private) }
let(:issue) { create(:issue, project: project, assignees: [user]) }
let(:user) { create(:user) }
subject(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) }
specify { expect(described_class).to require_graphql_authorizations(:update_issue) }
describe '#resolve' do
let(:confidential) { true }
let(:mutated_issue) { subject[:issue] }
subject { mutation.resolve(project_path: project.full_path, iid: issue.iid, confidential: confidential) }
before do
stub_spam_services
end
it_behaves_like 'permission level for issue mutation is correctly verified'
context 'when the user can update the issue' do
before do
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
context 'when guest user is an assignee' do
let(:project) { create(:project, :public) }
before do
project.add_guest(user)
end
it 'does not change issue confidentiality' do
expect(mutated_issue).to eq(issue)
expect(mutated_issue.confidential).to be_falsey
expect(subject[:errors]).to be_empty
end
end
end
end
|