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

42 lines
1.2 KiB
Ruby
Raw Normal View History

2020-10-24 23:57:45 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Update of an existing issue' do
include GraphqlHelpers
let_it_be(:current_user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:issue) { create(:issue, project: project) }
let(:input) do
{
2021-01-03 14:25:43 +05:30
'iid' => issue.iid.to_s,
'title' => 'new title',
'description' => 'new description',
'confidential' => true,
'dueDate' => Date.tomorrow.strftime('%Y-%m-%d')
2020-10-24 23:57:45 +05:30
}
end
2021-01-03 14:25:43 +05:30
let(:mutation) { graphql_mutation(:update_issue, input.merge(project_path: project.full_path, locked: true)) }
2020-10-24 23:57:45 +05:30
let(:mutation_response) { graphql_mutation_response(:update_issue) }
context 'the user is not allowed to update issue' do
2020-11-24 15:15:51 +05:30
it_behaves_like 'a mutation that returns a top-level access error'
2020-10-24 23:57:45 +05:30
end
context 'when user has permissions to update issue' do
before do
project.add_developer(current_user)
end
it 'updates the issue' do
post_graphql_mutation(mutation, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
2021-01-03 14:25:43 +05:30
expect(mutation_response['issue']).to include(input)
expect(mutation_response['issue']).to include('discussionLocked' => true)
2020-10-24 23:57:45 +05:30
end
end
end