2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe Mutations::Issues::SetConfidential do
|
2020-10-04 03:57:07 +05:30
|
|
|
let(:project) { create(:project, :private) }
|
|
|
|
let(:issue) { create(:issue, project: project, assignees: [user]) }
|
2020-01-01 13:55:28 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
subject(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) }
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
specify { expect(described_class).to require_graphql_authorizations(:update_issue) }
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
describe '#resolve' do
|
|
|
|
let(:confidential) { true }
|
|
|
|
let(:mutated_issue) { subject[:issue] }
|
|
|
|
|
2020-10-04 03:57:07 +05:30
|
|
|
subject { mutation.resolve(project_path: project.full_path, iid: issue.iid, confidential: confidential) }
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
it_behaves_like 'permission level for issue mutation is correctly verified'
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
context 'when the user can update the issue' do
|
|
|
|
before do
|
2020-10-04 03:57:07 +05:30
|
|
|
project.add_developer(user)
|
2020-01-01 13:55:28 +05:30
|
|
|
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
|
2020-10-04 03:57:07 +05:30
|
|
|
|
|
|
|
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
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
|
|
|
end
|