Commit d1cbcaf1 authored by Laura Montemayor's avatar Laura Montemayor Committed by lauraMon

Cleaned up some specs and refactored

* Uses Global ID
* Updates schema
parent 25b3a293
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
module Mutations module Mutations
module Ci module Ci
class Base < BaseMutation class Base < BaseMutation
argument :id, GraphQL::ID_TYPE, argument :id, ::Types::GlobalIDType[::Ci::Pipeline],
required: true, required: true,
description: 'The id of the pipeline to mutate' description: 'The id of the pipeline to mutate'
private private
def find_object(id:) def find_object(id:)
::Ci::Pipeline.find(id) GlobalID::Locator.locate(id)
end end
end end
end end
......
...@@ -1566,6 +1566,11 @@ type CiJobEdge { ...@@ -1566,6 +1566,11 @@ type CiJobEdge {
node: CiJob node: CiJob
} }
"""
Identifier of Ci::Pipeline
"""
scalar CiPipelineID
type CiStage { type CiStage {
""" """
Group of jobs for the stage Group of jobs for the stage
...@@ -10630,7 +10635,7 @@ input PipelineDestroyInput { ...@@ -10630,7 +10635,7 @@ input PipelineDestroyInput {
""" """
The id of the pipeline to mutate The id of the pipeline to mutate
""" """
id: ID! id: CiPipelineID!
} }
""" """
...@@ -10692,7 +10697,7 @@ input PipelineRetryInput { ...@@ -10692,7 +10697,7 @@ input PipelineRetryInput {
""" """
The id of the pipeline to mutate The id of the pipeline to mutate
""" """
id: ID! id: CiPipelineID!
} }
""" """
......
...@@ -4249,6 +4249,16 @@ ...@@ -4249,6 +4249,16 @@
"enumValues": null, "enumValues": null,
"possibleTypes": null "possibleTypes": null
}, },
{
"kind": "SCALAR",
"name": "CiPipelineID",
"description": "Identifier of Ci::Pipeline",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{ {
"kind": "OBJECT", "kind": "OBJECT",
"name": "CiStage", "name": "CiStage",
...@@ -31883,7 +31893,7 @@ ...@@ -31883,7 +31893,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "CiPipelineID",
"ofType": null "ofType": null
} }
}, },
...@@ -32083,7 +32093,7 @@ ...@@ -32083,7 +32093,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "CiPipelineID",
"ofType": null "ofType": null
} }
}, },
...@@ -9,13 +9,7 @@ RSpec.describe 'PipelineCancel' do ...@@ -9,13 +9,7 @@ RSpec.describe 'PipelineCancel' do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, :running, project: project, user: user) } let_it_be(:pipeline) { create(:ci_pipeline, :running, project: project, user: user) }
let(:mutation) do let(:mutation) { graphql_mutation(:pipeline_cancel, {}, 'errors') }
graphql_mutation(:pipeline_cancel, {},
<<-QL
errors
QL
)
end
let(:mutation_response) { graphql_mutation_response(:pipeline_cancel) } let(:mutation_response) { graphql_mutation_response(:pipeline_cancel) }
......
...@@ -11,13 +11,9 @@ RSpec.describe 'PipelineDestroy' do ...@@ -11,13 +11,9 @@ RSpec.describe 'PipelineDestroy' do
let(:mutation) do let(:mutation) do
variables = { variables = {
id: pipeline.id id: pipeline.to_global_id.to_s
} }
graphql_mutation(:pipeline_destroy, variables, graphql_mutation(:pipeline_destroy, variables, 'errors')
<<-QL
errors
QL
)
end end
it 'returns an error if the user is not allowed to destroy the pipeline' do it 'returns an error if the user is not allowed to destroy the pipeline' do
......
...@@ -11,7 +11,7 @@ RSpec.describe 'PipelineRetry' do ...@@ -11,7 +11,7 @@ RSpec.describe 'PipelineRetry' do
let(:mutation) do let(:mutation) do
variables = { variables = {
id: pipeline.id id: pipeline.to_global_id.to_s
} }
graphql_mutation(:pipeline_retry, variables, graphql_mutation(:pipeline_retry, variables,
<<-QL <<-QL
......
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