2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-10-01 12:41:57 +02:00
|
|
|
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
|