[GraphQL] expose dossier pdf, geojson and attestation

This commit is contained in:
Paul Chavard 2020-10-01 12:41:57 +02:00
parent e3f2421741
commit 0aa06d0197
8 changed files with 129 additions and 3 deletions

View file

@ -0,0 +1,38 @@
describe API::V2::DossiersController do
let(:dossier) { create(:dossier, :accepte, :with_attestation) }
let(:sgid) { dossier.to_sgid(expires_in: 1.hour, for: 'api_v2') }
describe 'fetch pdf' do
subject { get :pdf, params: { id: sgid } }
it 'should get' do
expect(subject.status).to eq(200)
expect(subject.body).not_to be_nil
end
context 'error' do
let(:sgid) { 'yolo' }
it 'should error' do
expect(subject.status).to eq(401)
end
end
end
describe 'fetch geojson' do
subject { get :geojson, params: { id: sgid } }
it 'should get' do
expect(subject.status).to eq(200)
expect(subject.body).not_to be_nil
end
context 'error' do
let(:sgid) { 'yolo' }
it 'should error' do
expect(subject.status).to eq(401)
end
end
end
end

View file

@ -436,6 +436,35 @@ describe API::V2::GraphqlController do
end
end
context "with links" do
let(:dossier) { create(:dossier, :accepte, :with_attestation, procedure: procedure) }
let(:query) do
"{
dossier(number: #{dossier.id}) {
id
number
pdf {
url
}
geojson {
url
}
attestation {
url
}
}
}"
end
it "urls should be returned" do
expect(gql_errors).to eq(nil)
expect(gql_data[:dossier][:pdf][:url]).not_to be_nil
expect(gql_data[:dossier][:geojson][:url]).not_to be_nil
expect(gql_data[:dossier][:attestation][:url]).not_to be_nil
end
end
context "when there are missing data" do
before do
dossier.etablissement.update!(entreprise_code_effectif_entreprise: nil, entreprise_capital_social: nil,