Avoid recreating service too often
This commit is contained in:
parent
eafd0e8348
commit
33f29f35ab
3 changed files with 2 additions and 28 deletions
|
@ -223,10 +223,6 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def get_value(table, column)
|
||||
DossierFieldService.new.get_value(self, table, column)
|
||||
end
|
||||
|
||||
def owner_name
|
||||
if etablissement.present?
|
||||
etablissement.entreprise_raison_sociale
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
= submit_tag "Enregistrer", class: 'button'
|
||||
|
||||
%tbody
|
||||
- dossier_field_service = DossierFieldService.new
|
||||
- @dossiers.each do |dossier|
|
||||
%tr
|
||||
%td.folder-col
|
||||
|
@ -107,7 +108,7 @@
|
|||
- @displayed_fields.each do |field|
|
||||
%td
|
||||
= link_to(gestionnaire_dossier_path(@procedure, dossier), class: 'cell-link') do
|
||||
= dossier.get_value(field['table'], field['column'])
|
||||
= dossier_field_service.get_value(dossier, field['table'], field['column'])
|
||||
|
||||
%td.status-col
|
||||
= link_to(gestionnaire_dossier_path(@procedure, dossier), class: 'cell-link') do
|
||||
|
|
|
@ -732,29 +732,6 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#get_value" do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user) }
|
||||
|
||||
before do
|
||||
FranceConnectInformation.create(france_connect_particulier_id: 123, user: user, gender: 'male')
|
||||
|
||||
@champ_public = dossier.champs.first
|
||||
@champ_public.value = "kiwi"
|
||||
@champ_public.save
|
||||
|
||||
@champ_private = dossier.champs_private.first
|
||||
@champ_private.value = "banane"
|
||||
@champ_private.save
|
||||
end
|
||||
|
||||
it { expect(dossier.get_value('self', 'created_at')).to eq(dossier.created_at) }
|
||||
it { expect(dossier.get_value('user', 'email')).to eq(user.email) }
|
||||
it { expect(dossier.get_value('etablissement', 'entreprise_siren')).to eq(dossier.etablissement.entreprise_siren) }
|
||||
it { expect(dossier.get_value('etablissement', 'siret')).to eq(dossier.etablissement.siret) }
|
||||
it { expect(dossier.get_value('type_de_champ', @champ_public.type_de_champ.id.to_s)).to eq(dossier.champs.first.value) }
|
||||
it { expect(dossier.get_value('type_de_champ_private', @champ_private.type_de_champ.id.to_s)).to eq(dossier.champs_private.first.value) }
|
||||
end
|
||||
|
||||
describe 'updated_at' do
|
||||
let!(:dossier) { create(:dossier) }
|
||||
let(:modif_date) { DateTime.parse('01/01/2100') }
|
||||
|
|
Loading…
Reference in a new issue