Merge pull request #7366 from tchak/graphql-repasser-en-instruction
feat(graphql): expose repasser_en_construction and repasser_en_instruction
This commit is contained in:
commit
edd68b1a3e
5 changed files with 236 additions and 0 deletions
27
app/graphql/mutations/dossier_repasser_en_construction.rb
Normal file
27
app/graphql/mutations/dossier_repasser_en_construction.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
module Mutations
|
||||||
|
class DossierRepasserEnConstruction < Mutations::BaseMutation
|
||||||
|
include DossierHelper
|
||||||
|
|
||||||
|
description "Re-passer le dossier en construction."
|
||||||
|
|
||||||
|
argument :dossier_id, ID, "Dossier ID", required: true, loads: Types::DossierType
|
||||||
|
argument :instructeur_id, ID, "Instructeur qui prend la décision sur le dossier.", required: true, loads: Types::ProfileType
|
||||||
|
argument :disable_notification, Boolean, "Désactiver l’envoi de l’email de notification après l’opération", required: false, default_value: false
|
||||||
|
|
||||||
|
field :dossier, Types::DossierType, null: true
|
||||||
|
field :errors, [Types::ValidationErrorType], null: true
|
||||||
|
|
||||||
|
def resolve(dossier:, instructeur:, disable_notification:)
|
||||||
|
dossier.repasser_en_construction!(instructeur)
|
||||||
|
|
||||||
|
{ dossier: dossier }
|
||||||
|
end
|
||||||
|
|
||||||
|
def authorized?(dossier:, instructeur:, **args)
|
||||||
|
if !dossier.en_instruction?
|
||||||
|
return false, { errors: ["Le dossier est déjà #{dossier_display_state(dossier, lower: true)}"] }
|
||||||
|
end
|
||||||
|
dossier_authorized_for?(dossier, instructeur)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
27
app/graphql/mutations/dossier_repasser_en_instruction.rb
Normal file
27
app/graphql/mutations/dossier_repasser_en_instruction.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
module Mutations
|
||||||
|
class DossierRepasserEnInstruction < Mutations::BaseMutation
|
||||||
|
include DossierHelper
|
||||||
|
|
||||||
|
description "Re-passer le dossier en instruction."
|
||||||
|
|
||||||
|
argument :dossier_id, ID, "Dossier ID", required: true, loads: Types::DossierType
|
||||||
|
argument :instructeur_id, ID, "Instructeur qui prend la décision sur le dossier.", required: true, loads: Types::ProfileType
|
||||||
|
argument :disable_notification, Boolean, "Désactiver l’envoi de l’email de notification après l’opération", required: false, default_value: false
|
||||||
|
|
||||||
|
field :dossier, Types::DossierType, null: true
|
||||||
|
field :errors, [Types::ValidationErrorType], null: true
|
||||||
|
|
||||||
|
def resolve(dossier:, instructeur:, disable_notification:)
|
||||||
|
dossier.repasser_en_instruction!(instructeur: instructeur, disable_notification: disable_notification)
|
||||||
|
|
||||||
|
{ dossier: dossier }
|
||||||
|
end
|
||||||
|
|
||||||
|
def authorized?(dossier:, instructeur:, **args)
|
||||||
|
if !dossier.termine?
|
||||||
|
return false, { errors: ["Le dossier est déjà #{dossier_display_state(dossier, lower: true)}"] }
|
||||||
|
end
|
||||||
|
dossier_authorized_for?(dossier, instructeur)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1291,6 +1291,80 @@ type DossierRefuserPayload {
|
||||||
errors: [ValidationError!]
|
errors: [ValidationError!]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
Autogenerated input type of DossierRepasserEnConstruction
|
||||||
|
"""
|
||||||
|
input DossierRepasserEnConstructionInput {
|
||||||
|
"""
|
||||||
|
A unique identifier for the client performing the mutation.
|
||||||
|
"""
|
||||||
|
clientMutationId: String
|
||||||
|
|
||||||
|
"""
|
||||||
|
Désactiver l’envoi de l’email de notification après l’opération
|
||||||
|
"""
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
|
||||||
|
"""
|
||||||
|
Dossier ID
|
||||||
|
"""
|
||||||
|
dossierId: ID!
|
||||||
|
|
||||||
|
"""
|
||||||
|
Instructeur qui prend la décision sur le dossier.
|
||||||
|
"""
|
||||||
|
instructeurId: ID!
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
Autogenerated return type of DossierRepasserEnConstruction
|
||||||
|
"""
|
||||||
|
type DossierRepasserEnConstructionPayload {
|
||||||
|
"""
|
||||||
|
A unique identifier for the client performing the mutation.
|
||||||
|
"""
|
||||||
|
clientMutationId: String
|
||||||
|
dossier: Dossier
|
||||||
|
errors: [ValidationError!]
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
Autogenerated input type of DossierRepasserEnInstruction
|
||||||
|
"""
|
||||||
|
input DossierRepasserEnInstructionInput {
|
||||||
|
"""
|
||||||
|
A unique identifier for the client performing the mutation.
|
||||||
|
"""
|
||||||
|
clientMutationId: String
|
||||||
|
|
||||||
|
"""
|
||||||
|
Désactiver l’envoi de l’email de notification après l’opération
|
||||||
|
"""
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
|
||||||
|
"""
|
||||||
|
Dossier ID
|
||||||
|
"""
|
||||||
|
dossierId: ID!
|
||||||
|
|
||||||
|
"""
|
||||||
|
Instructeur qui prend la décision sur le dossier.
|
||||||
|
"""
|
||||||
|
instructeurId: ID!
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
Autogenerated return type of DossierRepasserEnInstruction
|
||||||
|
"""
|
||||||
|
type DossierRepasserEnInstructionPayload {
|
||||||
|
"""
|
||||||
|
A unique identifier for the client performing the mutation.
|
||||||
|
"""
|
||||||
|
clientMutationId: String
|
||||||
|
dossier: Dossier
|
||||||
|
errors: [ValidationError!]
|
||||||
|
}
|
||||||
|
|
||||||
enum DossierState {
|
enum DossierState {
|
||||||
"""
|
"""
|
||||||
Accepté
|
Accepté
|
||||||
|
@ -1654,6 +1728,26 @@ type Mutation {
|
||||||
"""
|
"""
|
||||||
input: DossierRefuserInput!
|
input: DossierRefuserInput!
|
||||||
): DossierRefuserPayload
|
): DossierRefuserPayload
|
||||||
|
|
||||||
|
"""
|
||||||
|
Re-passer le dossier en construction.
|
||||||
|
"""
|
||||||
|
dossierRepasserEnConstruction(
|
||||||
|
"""
|
||||||
|
Parameters for DossierRepasserEnConstruction
|
||||||
|
"""
|
||||||
|
input: DossierRepasserEnConstructionInput!
|
||||||
|
): DossierRepasserEnConstructionPayload
|
||||||
|
|
||||||
|
"""
|
||||||
|
Re-passer le dossier en instruction.
|
||||||
|
"""
|
||||||
|
dossierRepasserEnInstruction(
|
||||||
|
"""
|
||||||
|
Parameters for DossierRepasserEnInstruction
|
||||||
|
"""
|
||||||
|
input: DossierRepasserEnInstructionInput!
|
||||||
|
): DossierRepasserEnInstructionPayload
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Order {
|
enum Order {
|
||||||
|
|
|
@ -7,6 +7,8 @@ module Types
|
||||||
field :dossier_classer_sans_suite, mutation: Mutations::DossierClasserSansSuite
|
field :dossier_classer_sans_suite, mutation: Mutations::DossierClasserSansSuite
|
||||||
field :dossier_refuser, mutation: Mutations::DossierRefuser
|
field :dossier_refuser, mutation: Mutations::DossierRefuser
|
||||||
field :dossier_accepter, mutation: Mutations::DossierAccepter
|
field :dossier_accepter, mutation: Mutations::DossierAccepter
|
||||||
|
field :dossier_repasser_en_instruction, mutation: Mutations::DossierRepasserEnInstruction
|
||||||
|
field :dossier_repasser_en_construction, mutation: Mutations::DossierRepasserEnConstruction
|
||||||
field :dossier_archiver, mutation: Mutations::DossierArchiver
|
field :dossier_archiver, mutation: Mutations::DossierArchiver
|
||||||
field :dossier_changer_groupe_instructeur, mutation: Mutations::DossierChangerGroupeInstructeur
|
field :dossier_changer_groupe_instructeur, mutation: Mutations::DossierChangerGroupeInstructeur
|
||||||
|
|
||||||
|
|
|
@ -1000,6 +1000,92 @@ describe API::V2::GraphqlController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'dossierRepasserEnInstruction' do
|
||||||
|
let(:dossiers) { [dossier2, dossier1, dossier] }
|
||||||
|
let(:dossier) { create(:dossier, :refuse, :with_individual, procedure: procedure) }
|
||||||
|
let(:instructeur_id) { instructeur.to_typed_id }
|
||||||
|
let(:disable_notification) { false }
|
||||||
|
let(:query) do
|
||||||
|
"mutation {
|
||||||
|
dossierRepasserEnInstruction(input: {
|
||||||
|
dossierId: \"#{dossier.to_typed_id}\",
|
||||||
|
instructeurId: \"#{instructeur_id}\",
|
||||||
|
disableNotification: #{disable_notification}
|
||||||
|
}) {
|
||||||
|
dossier {
|
||||||
|
id
|
||||||
|
state
|
||||||
|
motivation
|
||||||
|
}
|
||||||
|
errors {
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'success' do
|
||||||
|
it "should repasser en instruction dossier" do
|
||||||
|
expect(gql_errors).to eq(nil)
|
||||||
|
|
||||||
|
expect(gql_data).to eq(dossierRepasserEnInstruction: {
|
||||||
|
dossier: {
|
||||||
|
id: dossier.to_typed_id,
|
||||||
|
state: "en_instruction",
|
||||||
|
motivation: nil
|
||||||
|
},
|
||||||
|
errors: nil
|
||||||
|
})
|
||||||
|
|
||||||
|
perform_enqueued_jobs
|
||||||
|
expect(ActionMailer::Base.deliveries.size).to eq(4)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'dossierRepasserEnConstruction' do
|
||||||
|
let(:dossiers) { [dossier2, dossier1, dossier] }
|
||||||
|
let(:dossier) { create(:dossier, :en_instruction, :with_individual, procedure: procedure) }
|
||||||
|
let(:instructeur_id) { instructeur.to_typed_id }
|
||||||
|
let(:disable_notification) { false }
|
||||||
|
let(:query) do
|
||||||
|
"mutation {
|
||||||
|
dossierRepasserEnConstruction(input: {
|
||||||
|
dossierId: \"#{dossier.to_typed_id}\",
|
||||||
|
instructeurId: \"#{instructeur_id}\",
|
||||||
|
disableNotification: #{disable_notification}
|
||||||
|
}) {
|
||||||
|
dossier {
|
||||||
|
id
|
||||||
|
state
|
||||||
|
motivation
|
||||||
|
}
|
||||||
|
errors {
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'success' do
|
||||||
|
it "should passer en instruction dossier" do
|
||||||
|
expect(gql_errors).to eq(nil)
|
||||||
|
|
||||||
|
expect(gql_data).to eq(dossierRepasserEnConstruction: {
|
||||||
|
dossier: {
|
||||||
|
id: dossier.to_typed_id,
|
||||||
|
state: "en_construction",
|
||||||
|
motivation: nil
|
||||||
|
},
|
||||||
|
errors: nil
|
||||||
|
})
|
||||||
|
|
||||||
|
perform_enqueued_jobs
|
||||||
|
expect(ActionMailer::Base.deliveries.size).to eq(3)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'dossierClasserSansSuite' do
|
describe 'dossierClasserSansSuite' do
|
||||||
let(:dossier) { create(:dossier, :en_instruction, :with_individual, procedure: procedure) }
|
let(:dossier) { create(:dossier, :en_instruction, :with_individual, procedure: procedure) }
|
||||||
let(:query) do
|
let(:query) do
|
||||||
|
|
Loading…
Reference in a new issue