Merge pull request #3718 from betagouv/fix_siret_champ

Champ Siret: Fix siret-champ save
This commit is contained in:
Pierre de La Morinerie 2019-04-02 14:33:50 +02:00 committed by GitHub
commit 9a824b0460
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -13,9 +13,9 @@ class Champs::SiretController < ApplicationController
etablissement = find_etablisement_with_siret etablissement = find_etablisement_with_siret
if etablissement.present? if etablissement.present?
@etablissement = etablissement @etablissement = etablissement
if @champ.present?
etablissement.champ = @champ if !@champ.nil?
etablissement.save! @champ.update!(value: etablissement.siret, etablissement: etablissement)
end end
else else
@champ&.update!(value: '') @champ&.update!(value: '')

View file

@ -6,7 +6,7 @@ describe Champs::SiretController, type: :controller do
describe '#show' do describe '#show' do
let(:dossier) { create(:dossier, user: user, procedure: procedure) } let(:dossier) { create(:dossier, user: user, procedure: procedure) }
let(:champ) { create(:champ_siret, dossier: dossier) } let(:champ) { create(:champ_siret, dossier: dossier, value: nil, etablissement: nil) }
let(:params) do let(:params) do
{ {
champ_id: champ.id, champ_id: champ.id,