Merge pull request #6252 from tchak/fix-byte-size
GraphQL byte_size should be BigInt
This commit is contained in:
commit
667781ab1e
4 changed files with 72 additions and 3 deletions
|
@ -1131,7 +1131,8 @@ type Entreprise {
|
|||
}
|
||||
|
||||
type File {
|
||||
byteSize: Int!
|
||||
byteSize: Int! @deprecated(reason: "Utilisez le champ `byteSizeBigInt` à la place.")
|
||||
byteSizeBigInt: BigInt!
|
||||
checksum: String!
|
||||
contentType: String!
|
||||
filename: String!
|
||||
|
|
|
@ -2,7 +2,8 @@ module Types
|
|||
class File < Types::BaseObject
|
||||
field :url, Types::URL, null: false
|
||||
field :filename, String, null: false
|
||||
field :byte_size, Int, null: false
|
||||
field :byte_size, Int, null: false, deprecation_reason: "Utilisez le champ `byteSizeBigInt` à la place."
|
||||
field :byte_size_big_int, GraphQL::Types::BigInt, null: false, method: :byte_size
|
||||
field :checksum, String, null: false
|
||||
field :content_type, String, null: false
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ class SerializerService
|
|||
fragment FileFragment on File {
|
||||
filename
|
||||
checksum
|
||||
byteSize
|
||||
byteSize: byteSizeBigInt
|
||||
contentType
|
||||
}
|
||||
GRAPHQL
|
||||
|
|
|
@ -649,6 +649,73 @@ describe API::V2::GraphqlController do
|
|||
end
|
||||
end
|
||||
|
||||
context "champ" do
|
||||
let(:champ) { create(:champ_piece_justificative, dossier: dossier) }
|
||||
let(:byte_size) { 2712286911 }
|
||||
|
||||
context "byteSize" do
|
||||
let(:query) do
|
||||
"{
|
||||
dossier(number: #{dossier.id}) {
|
||||
champs(id: \"#{champ.to_typed_id}\") {
|
||||
... on PieceJustificativeChamp {
|
||||
file { byteSize }
|
||||
}
|
||||
}
|
||||
}
|
||||
}"
|
||||
end
|
||||
|
||||
it {
|
||||
expect(gql_errors).to be_nil
|
||||
expect(gql_data).to eq(dossier: { champs: [{ file: { byteSize: 4 } }] })
|
||||
}
|
||||
end
|
||||
|
||||
context "when file is really big" do
|
||||
before do
|
||||
champ.piece_justificative_file.blob.update(byte_size: byte_size)
|
||||
end
|
||||
|
||||
context "byteSize" do
|
||||
let(:query) do
|
||||
"{
|
||||
dossier(number: #{dossier.id}) {
|
||||
champs(id: \"#{champ.to_typed_id}\") {
|
||||
... on PieceJustificativeChamp {
|
||||
file { byteSize }
|
||||
}
|
||||
}
|
||||
}
|
||||
}"
|
||||
end
|
||||
|
||||
it {
|
||||
expect(gql_errors).not_to be_nil
|
||||
}
|
||||
end
|
||||
|
||||
context "byteSizeBigInt" do
|
||||
let(:query) do
|
||||
"{
|
||||
dossier(number: #{dossier.id}) {
|
||||
champs(id: \"#{champ.to_typed_id}\") {
|
||||
... on PieceJustificativeChamp {
|
||||
file { byteSizeBigInt }
|
||||
}
|
||||
}
|
||||
}
|
||||
}"
|
||||
end
|
||||
|
||||
it {
|
||||
expect(gql_errors).to be_nil
|
||||
expect(gql_data).to eq(dossier: { champs: [{ file: { byteSizeBigInt: '2712286911' } }] })
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "groupeInstructeur" do
|
||||
let(:groupe_instructeur) { procedure.groupe_instructeurs.first }
|
||||
let(:query) do
|
||||
|
|
Loading…
Reference in a new issue