Add Cerfa on API Show dossier

This commit is contained in:
Xavier J 2016-03-14 11:10:02 +01:00
parent b49770f408
commit e944364929
2 changed files with 16 additions and 2 deletions

View file

@ -1,4 +1,5 @@
class CerfaSerializer < ActiveModel::Serializer
attributes :content_url => :url
end

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe API::V1::DossiersController do
let(:admin) { create(:administrateur) }
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, administrateur: admin) }
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, administrateur: admin, cerfa_flag: true) }
let(:wrong_procedure) { create(:procedure) }
it { expect(described_class).to be < APIController }
@ -116,7 +116,7 @@ describe API::V1::DossiersController do
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure) } }
let(:dossier_id) { dossier.id }
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
let(:field_list) { [:id, :nom_projet, :created_at, :updated_at, :description, :archived, :mandataire_social, :entreprise, :etablissement, :cerfa, :pieces_justificatives, :champs] }
let(:field_list) { [:id, :nom_projet, :created_at, :updated_at, :description, :archived, :mandataire_social, :entreprise, :etablissement, :cerfa, :pieces_justificatives, :champs, :commentaires] }
subject { body[:dossier] }
it 'return REST code 200', :show_in_doc do
@ -232,6 +232,19 @@ describe API::V1::DossiersController do
it { expect(subject.first[:email]).to eq 'plop@plip.com' }
end
describe 'cerfa' do
let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
before do
dossier.cerfa.content = content
dossier.cerfa.save
end
subject { super()[:cerfa] }
it { expect(subject[:url]).to match /^http:\/\/.*downloads.*_CERFA\.pdf$/ }
end
describe 'etablissement' do
let(:field_list) { [
:siret,