Add invites to API

This commit is contained in:
Mathieu Magnin 2017-04-14 18:20:14 +02:00
parent 40d897f538
commit 757af12d42
4 changed files with 11 additions and 2 deletions

View file

@ -22,6 +22,7 @@ class Dossier < ActiveRecord::Base
has_many :commentaires, dependent: :destroy
has_many :invites, dependent: :destroy
has_many :invites_user, class_name: 'InviteUser', dependent: :destroy
has_many :invites_gestionnaires, class_name: 'InviteGestionnaire', dependent: :destroy
has_many :follows
has_many :notifications, dependent: :destroy

View file

@ -9,7 +9,8 @@ class DossierSerializer < ActiveModel::Serializer
:initiated_at,
:received_at,
:processed_at,
:accompagnateurs
:accompagnateurs,
:invites
has_one :entreprise
has_one :etablissement
@ -27,4 +28,8 @@ class DossierSerializer < ActiveModel::Serializer
def accompagnateurs
object.followers_gestionnaires.pluck(:email)
end
def invites
object.invites_gestionnaires.pluck(:email)
end
end

View file

@ -53,6 +53,9 @@
"accompagnateurs": [
"gestionnaire@apientreprise.fr"
],
"invites": [
"nom@domaine.fr"
],
"entreprise": {
"siren": "440117620",
"capital_social": 537100000,

View file

@ -115,7 +115,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, :created_at, :updated_at, :archived, :mandataire_social, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :accompagnateurs] }
let(:field_list) { [:id, :created_at, :updated_at, :archived, :mandataire_social, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :accompagnateurs, :invites] }
subject { body[:dossier] }
it 'return REST code 200', :show_in_doc do