Merge pull request #641 from sgmap/395_export_user_email
395 export user email
This commit is contained in:
commit
348d6210a8
4 changed files with 24 additions and 12 deletions
|
@ -3,6 +3,7 @@ class DossierSerializer < ActiveModel::Serializer
|
||||||
:created_at,
|
:created_at,
|
||||||
:updated_at,
|
:updated_at,
|
||||||
:archived,
|
:archived,
|
||||||
|
:email,
|
||||||
:mandataire_social,
|
:mandataire_social,
|
||||||
:state,
|
:state,
|
||||||
:simplified_state,
|
:simplified_state,
|
||||||
|
@ -22,6 +23,10 @@ class DossierSerializer < ActiveModel::Serializer
|
||||||
has_many :pieces_justificatives
|
has_many :pieces_justificatives
|
||||||
has_many :types_de_piece_justificative
|
has_many :types_de_piece_justificative
|
||||||
|
|
||||||
|
def email
|
||||||
|
object.user.try(:email)
|
||||||
|
end
|
||||||
|
|
||||||
def simplified_state
|
def simplified_state
|
||||||
object.decorate.display_state
|
object.decorate.display_state
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,7 @@ class DossierTableExportSerializer < ActiveModel::Serializer
|
||||||
:created_at,
|
:created_at,
|
||||||
:updated_at,
|
:updated_at,
|
||||||
:archived,
|
:archived,
|
||||||
|
:email,
|
||||||
:mandataire_social,
|
:mandataire_social,
|
||||||
:state,
|
:state,
|
||||||
:initiated_at,
|
:initiated_at,
|
||||||
|
@ -17,6 +18,10 @@ class DossierTableExportSerializer < ActiveModel::Serializer
|
||||||
:individual_nom,
|
:individual_nom,
|
||||||
:individual_birthdate
|
:individual_birthdate
|
||||||
|
|
||||||
|
def email
|
||||||
|
object.user.try(:email)
|
||||||
|
end
|
||||||
|
|
||||||
def individual_prenom
|
def individual_prenom
|
||||||
object.individual.try(:prenom)
|
object.individual.try(:prenom)
|
||||||
end
|
end
|
||||||
|
|
|
@ -114,7 +114,7 @@ describe API::V1::DossiersController do
|
||||||
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, motivation: "Motivation") } }
|
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, motivation: "Motivation") } }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
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, :motivation, :accompagnateurs, :invites] }
|
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, :motivation, :email, :accompagnateurs, :invites] }
|
||||||
subject { body[:dossier] }
|
subject { body[:dossier] }
|
||||||
|
|
||||||
it 'return REST code 200', :show_in_doc do
|
it 'return REST code 200', :show_in_doc do
|
||||||
|
|
|
@ -482,18 +482,19 @@ describe Dossier do
|
||||||
it { expect(subject[1]).to be_a_kind_of(Time) }
|
it { expect(subject[1]).to be_a_kind_of(Time) }
|
||||||
it { expect(subject[2]).to be_a_kind_of(Time) }
|
it { expect(subject[2]).to be_a_kind_of(Time) }
|
||||||
it { expect(subject[3]).to be_in([true, false]) }
|
it { expect(subject[3]).to be_in([true, false]) }
|
||||||
it { expect(subject[4]).to be_in([true, false]) }
|
it { expect(subject[4]).to eq(dossier.user.email) }
|
||||||
it { expect(subject[5]).to eq("draft") }
|
it { expect(subject[5]).to be_in([true, false]) }
|
||||||
it { expect(subject[6]).to eq(date1) }
|
it { expect(subject[6]).to eq("draft") }
|
||||||
it { expect(subject[7]).to eq(date2) }
|
it { expect(subject[7]).to eq(date1) }
|
||||||
it { expect(subject[8]).to eq(date3) }
|
it { expect(subject[8]).to eq(date2) }
|
||||||
it { expect(subject[9]).to be_a_kind_of(String) }
|
it { expect(subject[9]).to eq(date3) }
|
||||||
it { expect(subject[10]).to be_a_kind_of(String) }
|
it { expect(subject[10]).to be_a_kind_of(String) }
|
||||||
it { expect(subject[11]).to be_nil }
|
it { expect(subject[11]).to be_a_kind_of(String) }
|
||||||
it { expect(subject[12]).to be_nil }
|
it { expect(subject[12]).to be_nil }
|
||||||
it { expect(subject[13]).to be_nil }
|
it { expect(subject[13]).to be_nil }
|
||||||
it { expect(subject[14]).to be_nil }
|
it { expect(subject[14]).to be_nil }
|
||||||
it { expect(subject[15]).to be_nil }
|
it { expect(subject[15]).to be_nil }
|
||||||
|
it { expect(subject[16]).to be_nil }
|
||||||
it { expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count +
|
it { expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count +
|
||||||
dossier.procedure.types_de_champ.count +
|
dossier.procedure.types_de_champ.count +
|
||||||
dossier.procedure.types_de_champ_private.count +
|
dossier.procedure.types_de_champ_private.count +
|
||||||
|
@ -505,10 +506,10 @@ describe Dossier do
|
||||||
|
|
||||||
subject { dossier_with_individual.data_with_champs }
|
subject { dossier_with_individual.data_with_champs }
|
||||||
|
|
||||||
it { expect(subject[11]).to eq(dossier_with_individual.individual.gender) }
|
it { expect(subject[12]).to eq(dossier_with_individual.individual.gender) }
|
||||||
it { expect(subject[12]).to eq(dossier_with_individual.individual.prenom) }
|
it { expect(subject[13]).to eq(dossier_with_individual.individual.prenom) }
|
||||||
it { expect(subject[13]).to eq(dossier_with_individual.individual.nom) }
|
it { expect(subject[14]).to eq(dossier_with_individual.individual.nom) }
|
||||||
it { expect(subject[14]).to eq(dossier_with_individual.individual.birthdate) }
|
it { expect(subject[15]).to eq(dossier_with_individual.individual.birthdate) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -519,6 +520,7 @@ describe Dossier do
|
||||||
dossier.created_at,
|
dossier.created_at,
|
||||||
dossier.updated_at,
|
dossier.updated_at,
|
||||||
"false",
|
"false",
|
||||||
|
dossier.user.email,
|
||||||
"false",
|
"false",
|
||||||
"draft",
|
"draft",
|
||||||
dossier.initiated_at,
|
dossier.initiated_at,
|
||||||
|
|
Loading…
Reference in a new issue