debian-mirror-gitlab/spec/graphql/mutations/issues/update_spec.rb

56 lines
1.5 KiB
Ruby
Raw Normal View History

2020-04-08 14:13:33 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Mutations::Issues::Update do
2020-04-08 14:13:33 +05:30
let(:issue) { create(:issue) }
let(:user) { create(:user) }
let(:expected_attributes) do
{
title: 'new title',
description: 'new description',
confidential: true,
due_date: Date.tomorrow
}
end
let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) }
let(:mutated_issue) { subject[:issue] }
2020-05-24 23:13:21 +05:30
specify { expect(described_class).to require_graphql_authorizations(:update_issue) }
2020-04-08 14:13:33 +05:30
describe '#resolve' do
let(:mutation_params) do
{
project_path: issue.project.full_path,
iid: issue.iid
}.merge(expected_attributes)
end
subject { mutation.resolve(mutation_params) }
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 'updates issue with correct values' do
subject
expect(issue.reload).to have_attributes(expected_attributes)
end
context 'when iid does not exist' do
it 'raises resource not available error' do
2020-04-22 19:07:51 +05:30
mutation_params[:iid] = non_existing_record_iid
2020-04-08 14:13:33 +05:30
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end
end
end
end