44 lines
1.6 KiB
Ruby
44 lines
1.6 KiB
Ruby
RSpec.describe Types::DemarcheType, type: :graphql do
|
|
let(:query) { '' }
|
|
let(:context) { { internal_use: true } }
|
|
let(:variables) { {} }
|
|
|
|
subject { API::V2::Schema.execute(query, variables: variables, context: context) }
|
|
|
|
let(:data) { subject['data'].deep_symbolize_keys }
|
|
let(:errors) { subject['errors'].deep_symbolize_keys }
|
|
|
|
describe 'demarche with clone' do
|
|
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :yes_no }]) }
|
|
let(:procedure_clone) { procedure.clone(procedure.administrateurs.first, false) }
|
|
let(:query) { DEMARCHE_WITH_CHAMP_DESCRIPTORS_QUERY }
|
|
let(:variables) { { number: procedure_clone.id } }
|
|
let(:champ_descriptor_id) { procedure.draft_revision.types_de_champ_public.first.to_typed_id }
|
|
|
|
it {
|
|
expect(data[:demarche][:champDescriptors]).to eq(data[:demarche][:draftRevision][:champDescriptors])
|
|
expect(data[:demarche][:champDescriptors][0][:id]).to eq(champ_descriptor_id)
|
|
expect(data[:demarche][:draftRevision][:champDescriptors][0][:id]).to eq(champ_descriptor_id)
|
|
expect(procedure.draft_revision.types_de_champ_public.first.id).not_to eq(procedure_clone.draft_revision.types_de_champ_public.first.id)
|
|
expect(procedure.draft_revision.types_de_champ_public.first.stable_id).to eq(procedure_clone.draft_revision.types_de_champ_public.first.stable_id)
|
|
}
|
|
end
|
|
|
|
DEMARCHE_WITH_CHAMP_DESCRIPTORS_QUERY = <<-GRAPHQL
|
|
query($number: Int!) {
|
|
demarche(number: $number) {
|
|
number
|
|
champDescriptors {
|
|
id
|
|
label
|
|
}
|
|
draftRevision {
|
|
champDescriptors {
|
|
id
|
|
label
|
|
}
|
|
}
|
|
}
|
|
}
|
|
GRAPHQL
|
|
end
|