From 0d80c48b7e45c27cd57c7950a1ee25eb9a2c074e Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 27 Jun 2019 14:38:57 +0200 Subject: [PATCH] Add avis to api --- app/models/dossier.rb | 1 + app/serializers/dossier_serializer.rb | 1 + spec/controllers/api/v1/dossiers_controller_spec.rb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 3449517ec..b5b531cb6 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -79,6 +79,7 @@ class Dossier < ApplicationRecord piece_justificative_file_attachment: :blob ], pieces_justificatives: [], + avis: [], etablissement: [], individual: [], user: []) diff --git a/app/serializers/dossier_serializer.rb b/app/serializers/dossier_serializer.rb index 876b2dcaf..980254ce3 100644 --- a/app/serializers/dossier_serializer.rb +++ b/app/serializers/dossier_serializer.rb @@ -23,6 +23,7 @@ class DossierSerializer < ActiveModel::Serializer has_many :pieces_justificatives has_many :types_de_piece_justificative has_one :justificatif_motivation + has_many :avis has_many :champs, serializer: ChampSerializer diff --git a/spec/controllers/api/v1/dossiers_controller_spec.rb b/spec/controllers/api/v1/dossiers_controller_spec.rb index 0e8a01186..fee71b685 100644 --- a/spec/controllers/api/v1/dossiers_controller_spec.rb +++ b/spec/controllers/api/v1/dossiers_controller_spec.rb @@ -157,7 +157,7 @@ describe API::V1::DossiersController do let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :en_construction, procedure: procedure, motivation: "Motivation") } } let(:dossier_id) { dossier.id } let(:body) { JSON.parse(retour.body, symbolize_names: true) } - let(:field_list) { [:id, :created_at, :updated_at, :archived, :individual, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :motivation, :email, :instructeurs, :justificatif_motivation] } + let(:field_list) { [:id, :created_at, :updated_at, :archived, :individual, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :motivation, :email, :instructeurs, :justificatif_motivation, :avis] } subject { body[:dossier] } it 'return REST code 200', :show_in_doc do