api: remove export of old pieces justificatives

This commit is contained in:
Pierre de La Morinerie 2019-07-25 12:54:54 +00:00
parent e975fe4ade
commit f69f325236
8 changed files with 6 additions and 78 deletions

View file

@ -128,7 +128,6 @@ class Dossier < ApplicationRecord
:etablissement, :etablissement,
piece_justificative_file_attachment: :blob piece_justificative_file_attachment: :blob
], ],
pieces_justificatives: [],
avis: [], avis: [],
etablissement: [], etablissement: [],
individual: [], individual: [],

View file

@ -51,7 +51,6 @@ class Procedure < ApplicationRecord
:administrateurs, :administrateurs,
:types_de_champ_private, :types_de_champ_private,
:types_de_champ, :types_de_champ,
:types_de_piece_justificative,
:module_api_carto :module_api_carto
) )
} }

View file

@ -50,7 +50,6 @@ class DossierSerializer < ActiveModel::Serializer
end end
def pieces_justificatives def pieces_justificatives
ActiveModelSerializers::SerializableResource.new(object.pieces_justificatives).serializable_hash +
PiecesJustificativesService.serialize_champs_as_pjs(object) PiecesJustificativesService.serialize_champs_as_pjs(object)
end end
@ -61,7 +60,6 @@ class DossierSerializer < ActiveModel::Serializer
end end
def types_de_piece_justificative def types_de_piece_justificative
ActiveModelSerializers::SerializableResource.new(object.types_de_piece_justificative).serializable_hash +
PiecesJustificativesService.serialize_types_de_champ_as_type_pj(object) PiecesJustificativesService.serialize_types_de_champ_as_type_pj(object)
end end

View file

@ -1,11 +0,0 @@
class PieceJustificativeSerializer < ActiveModel::Serializer
attributes :created_at,
:type_de_piece_justificative_id,
:content_url
has_one :user
def created_at
object.created_at&.in_time_zone('UTC')
end
end

View file

@ -49,7 +49,6 @@ class ProcedureSerializer < ActiveModel::Serializer
end end
def types_de_piece_justificative def types_de_piece_justificative
ActiveModelSerializers::SerializableResource.new(object.types_de_piece_justificative).serializable_hash +
PiecesJustificativesService.serialize_types_de_champ_as_type_pj(object) PiecesJustificativesService.serialize_types_de_champ_as_type_pj(object)
end end
end end

View file

@ -1,7 +0,0 @@
class TypeDePieceJustificativeSerializer < ActiveModel::Serializer
attributes :id,
:libelle,
:description,
:order_place,
:lien_demarche
end

View file

@ -3,7 +3,7 @@ require 'spec_helper'
describe API::V1::DossiersController do describe API::V1::DossiersController do
let(:admin) { create(:administrateur) } let(:admin) { create(:administrateur) }
let(:token) { admin.renew_api_token } let(:token) { admin.renew_api_token }
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private, administrateur: admin) } let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private, administrateur: admin) }
let(:wrong_procedure) { create(:procedure) } let(:wrong_procedure) { create(:procedure) }
it { expect(described_class).to be < APIController } it { expect(described_class).to be < APIController }
@ -204,49 +204,13 @@ describe API::V1::DossiersController do
it { expect(subject.keys).to match_array(field_list) } it { expect(subject.keys).to match_array(field_list) }
end end
describe 'types_de_piece_justificative' do
let(:field_list) { [:id, :libelle, :description] }
subject { super()[:types_de_piece_justificative] }
it { expect(subject.length).to eq 2 }
describe 'first type de piece justificative' do
subject { super().first }
it { expect(subject.key?(:id)).to be_truthy }
it { expect(subject[:libelle]).to eq('RIB') }
it { expect(subject[:description]).to eq('Releve identité bancaire') }
end
end
describe 'piece justificative', vcr: { cassette_name: 'controllers_api_v1_dossiers_controller_piece_justificative' } do
before do
create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative: dossier.procedure.types_de_piece_justificative.first, user: dossier.user
end
let(:field_list) { [:url, :created_at, :type_de_piece_justificative_id] }
subject { super()[:pieces_justificatives].first }
it { expect(subject.key?(:content_url)).to be_truthy }
it { expect(subject[:created_at]).not_to be_nil }
it { expect(subject[:type_de_piece_justificative_id]).not_to be_nil }
it { expect(subject.key?(:user)).to be_truthy }
describe 'user' do
subject { super()[:user] }
it { expect(subject[:email]).not_to be_nil }
end
end
describe 'champs' do describe 'champs' do
let(:field_list) { [:url] } let(:field_list) { [:url] }
subject { super()[:champs] } subject { super()[:champs] }
it { expect(subject.length).to eq 1 } it { expect(subject.length).to eq 1 }
describe 'first champs' do describe 'first champ' do
subject { super().first } subject { super().first }
it { expect(subject.key?(:value)).to be_truthy } it { expect(subject.key?(:value)).to be_truthy }

View file

@ -25,7 +25,7 @@ describe API::V1::ProceduresController, type: :controller do
it { is_expected.to have_http_status(200) } it { is_expected.to have_http_status(200) }
describe 'body' do describe 'body' do
let(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative, administrateur: admin) } let(:procedure) { create(:procedure, :with_type_de_champ, administrateur: admin) }
let(:response) { get :show, params: { id: procedure.id, token: token } } let(:response) { get :show, params: { id: procedure.id, token: token } }
subject { JSON.parse(response.body, symbolize_names: true)[:procedure] } subject { JSON.parse(response.body, symbolize_names: true)[:procedure] }
@ -51,19 +51,6 @@ describe API::V1::ProceduresController, type: :controller do
it { expect(subject[:order_place]).to eq(champ.order_place) } it { expect(subject[:order_place]).to eq(champ.order_place) }
it { expect(subject[:description]).to eq(champ.description) } it { expect(subject[:description]).to eq(champ.description) }
end end
it { is_expected.to have_key(:types_de_piece_justificative) }
it { expect(subject[:types_de_piece_justificative]).to be_an(Array) }
describe 'type_de_piece_jointe' do
subject { super()[:types_de_piece_justificative][0] }
let(:pj) { procedure.types_de_piece_justificative.first }
it { expect(subject[:id]).to eq(pj.id) }
it { expect(subject[:libelle]).to eq(pj.libelle) }
it { expect(subject[:description]).to eq(pj.description) }
end
end end
end end
end end