[GraphQL] expose dossier pdf, geojson and attestation
This commit is contained in:
parent
e3f2421741
commit
0aa06d0197
8 changed files with 129 additions and 3 deletions
38
spec/controllers/api/v2/dossiers_controller_spec.rb
Normal file
38
spec/controllers/api/v2/dossiers_controller_spec.rb
Normal 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
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue