Commit 9611e4fc authored by Matthias Käppler's avatar Matthias Käppler

Merge branch '346041-enable-work-items-ff-actors' into 'master'

Add actor to work_items FF on WorkItemCreate mutation

See merge request gitlab-org/gitlab!80659
parents 4d63b004 1dd22b11
...@@ -8,6 +8,9 @@ module Mutations ...@@ -8,6 +8,9 @@ module Mutations
include Mutations::SpamProtection include Mutations::SpamProtection
include FindsProject include FindsProject
description "Creates a work item." \
" Available only when feature flag `work_items` is enabled. The feature is experimental and is subject to change without notice."
authorize :create_work_item authorize :create_work_item
argument :description, GraphQL::Types::String, argument :description, GraphQL::Types::String,
...@@ -29,6 +32,11 @@ module Mutations ...@@ -29,6 +32,11 @@ module Mutations
def resolve(project_path:, **attributes) def resolve(project_path:, **attributes)
project = authorized_find!(project_path) project = authorized_find!(project_path)
unless Feature.enabled?(:work_items, project)
return { errors: ['`work_items` feature flag disabled for this project'] }
end
params = global_id_compatibility_params(attributes).merge(author_id: current_user.id) params = global_id_compatibility_params(attributes).merge(author_id: current_user.id)
spam_params = ::Spam::SpamParams.new_from_request(request: context[:request]) spam_params = ::Spam::SpamParams.new_from_request(request: context[:request])
......
...@@ -125,7 +125,7 @@ module Types ...@@ -125,7 +125,7 @@ module Types
mount_mutation Mutations::Packages::Destroy mount_mutation Mutations::Packages::Destroy
mount_mutation Mutations::Packages::DestroyFile mount_mutation Mutations::Packages::DestroyFile
mount_mutation Mutations::Echo mount_mutation Mutations::Echo
mount_mutation Mutations::WorkItems::Create, feature_flag: :work_items mount_mutation Mutations::WorkItems::Create
mount_mutation Mutations::WorkItems::Delete mount_mutation Mutations::WorkItems::Delete
mount_mutation Mutations::WorkItems::Update mount_mutation Mutations::WorkItems::Update
end end
......
...@@ -5168,7 +5168,7 @@ Input type: `VulnerabilityRevertToDetectedInput` ...@@ -5168,7 +5168,7 @@ Input type: `VulnerabilityRevertToDetectedInput`
### `Mutation.workItemCreate` ### `Mutation.workItemCreate`
Available only when feature flag `work_items` is enabled. This flag is disabled by default, because the feature is experimental and is subject to change without notice. Creates a work item. Available only when feature flag `work_items` is enabled. The feature is experimental and is subject to change without notice.
Input type: `WorkItemCreateInput` Input type: `WorkItemCreateInput`
...@@ -68,8 +68,13 @@ RSpec.describe 'Create a work item' do ...@@ -68,8 +68,13 @@ RSpec.describe 'Create a work item' do
stub_feature_flags(work_items: false) stub_feature_flags(work_items: false)
end end
it_behaves_like 'a mutation that returns top-level errors', it 'does not create the work item and returns an error' do
errors: ["Field 'workItemCreate' doesn't exist on type 'Mutation'", "Variable $workItemCreateInput is declared by anonymous mutation but not used"] expect do
post_graphql_mutation(mutation, current_user: current_user)
end.to not_change(WorkItem, :count)
expect(mutation_response['errors']).to contain_exactly('`work_items` feature flag disabled for this project')
end
end end
end end
end end
...@@ -71,10 +71,11 @@ RSpec.describe 'Update a work item' do ...@@ -71,10 +71,11 @@ RSpec.describe 'Update a work item' do
stub_feature_flags(work_items: false) stub_feature_flags(work_items: false)
end end
it 'does nothing and returns and error' do it 'does not update the work item and returns and error' do
expect do expect do
post_graphql_mutation(mutation, current_user: current_user) post_graphql_mutation(mutation, current_user: current_user)
end.to not_change(WorkItem, :count) work_item.reload
end.to not_change(work_item, :title)
expect(mutation_response['errors']).to contain_exactly('`work_items` feature flag disabled for this project') expect(mutation_response['errors']).to contain_exactly('`work_items` feature flag disabled for this project')
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment