diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 644f197da..92c715abe 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -2085,6 +2085,7 @@ type TextChamp implements Champ { } type TitreIdentiteChamp implements Champ { + filled: Boolean! grantType: TitreIdentiteGrantType! id: ID! diff --git a/app/graphql/types/champs/titre_identite_champ_type.rb b/app/graphql/types/champs/titre_identite_champ_type.rb index df137607b..ee4ae9ce6 100644 --- a/app/graphql/types/champs/titre_identite_champ_type.rb +++ b/app/graphql/types/champs/titre_identite_champ_type.rb @@ -8,9 +8,14 @@ module Types::Champs end field :grant_type, TitreIdentiteGrantTypeType, null: false + field :filled, Boolean, null: false def grant_type TypesDeChamp::TitreIdentiteTypeDeChamp::PIECE_JUSTIFICATIVE end + + def filled + object.piece_justificative_file.attached? + end end end diff --git a/app/models/champs/titre_identite_champ.rb b/app/models/champs/titre_identite_champ.rb index 22348d4b9..139c204fe 100644 --- a/app/models/champs/titre_identite_champ.rb +++ b/app/models/champs/titre_identite_champ.rb @@ -41,6 +41,6 @@ class Champs::TitreIdentiteChamp < Champ end def for_api - piece_justificative_file.attached? ? "présent" : "absent" + nil end end diff --git a/spec/models/champs/titre_identite_champ_spec.rb b/spec/models/champs/titre_identite_champ_spec.rb index ae6c7e266..8311ccf72 100644 --- a/spec/models/champs/titre_identite_champ_spec.rb +++ b/spec/models/champs/titre_identite_champ_spec.rb @@ -11,17 +11,4 @@ describe Champs::TitreIdentiteChamp do it { is_expected.to eq('absent') } end end - - describe '#for_api' do - let(:champ_titre_identite) { create(:champ_titre_identite) } - - subject { champ_titre_identite.for_api } - - it { is_expected.to eq('présent') } - - context 'without attached file' do - before { champ_titre_identite.piece_justificative_file.purge } - it { is_expected.to eq('absent') } - end - end end