Add DateTime champ to GraphQL

This commit is contained in:
Paul Chavard 2020-12-18 11:21:03 +01:00
parent d509fe2edb
commit dc08993a89
6 changed files with 144 additions and 3 deletions

View file

@ -409,6 +409,7 @@ describe API::V2::GraphqlController do
}
}"
end
context "in the nominal case" do
it "should be returned" do
expect(gql_errors).to eq(nil)
@ -497,6 +498,93 @@ describe API::V2::GraphqlController do
end
end
end
context "champs" do
let(:procedure) { create(:procedure, :published, :for_individual, administrateurs: [admin], types_de_champ: [type_de_champ_date, type_de_champ_datetime]) }
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
let(:type_de_champ_date) { build(:type_de_champ_date) }
let(:type_de_champ_datetime) { build(:type_de_champ_datetime) }
let(:champ_date) { dossier.champs.first }
let(:champ_datetime) { dossier.champs.second }
before do
champ_date.update(value: '2019-07-10')
champ_datetime.update(value: '15/09/1962 15:35')
end
context "with Date" do
let(:query) do
"{
dossier(number: #{dossier.id}) {
champs {
id
label
... on DateChamp {
value
}
}
}
}"
end
it "should be returned" do
expect(gql_errors).to eq(nil)
expect(gql_data).to eq(dossier: {
champs: [
{
id: champ_date.to_typed_id,
label: champ_date.libelle,
value: '2019-07-10T00:00:00+02:00'
},
{
id: champ_datetime.to_typed_id,
label: champ_datetime.libelle,
value: '1962-09-15T15:35:00+01:00'
}
]
})
end
end
context "with Datetime" do
let(:query) do
"{
dossier(number: #{dossier.id}) {
champs {
id
label
... on DateChamp {
value
date
}
... on DatetimeChamp {
datetime
}
}
}
}"
end
it "should be returned" do
expect(gql_errors).to eq(nil)
expect(gql_data).to eq(dossier: {
champs: [
{
id: champ_date.to_typed_id,
label: champ_date.libelle,
value: '2019-07-10T00:00:00+02:00',
date: '2019-07-10'
},
{
id: champ_datetime.to_typed_id,
label: champ_datetime.libelle,
datetime: '1962-09-15T15:35:00+01:00'
}
]
})
end
end
end
end
context "groupeInstructeur" do