don't clean the siret champ value
Cleaning the value is useless, when fetching the etablissement, as the value will be re-written by the dossier update, when the user fills in the dossier.
This commit is contained in:
parent
3eb76d8a43
commit
df2eaa9542
3 changed files with 9 additions and 19 deletions
|
@ -27,7 +27,7 @@ module SiretChampEtablissementFetchableConcern
|
|||
|
||||
def clear(error: nil)
|
||||
etablissement_to_destroy = etablissement
|
||||
update!(value: '', etablissement: nil)
|
||||
update!(etablissement: nil)
|
||||
etablissement_to_destroy&.destroy
|
||||
error.presence
|
||||
end
|
||||
|
|
|
@ -39,10 +39,8 @@ describe Champs::SiretController, type: :controller do
|
|||
context 'when the SIRET is empty' do
|
||||
subject! { get :show, params: params, format: :turbo_stream }
|
||||
|
||||
it 'clears the etablissement and SIRET on the model' do
|
||||
champ.reload
|
||||
expect(champ.etablissement).to be_nil
|
||||
expect(champ.value).to be_empty
|
||||
it 'clears the etablissement on the model' do
|
||||
expect(champ.reload.etablissement).to be_nil
|
||||
end
|
||||
|
||||
it 'clears any information or error message' do
|
||||
|
@ -55,10 +53,8 @@ describe Champs::SiretController, type: :controller do
|
|||
|
||||
subject! { get :show, params: params, format: :turbo_stream }
|
||||
|
||||
it 'clears the etablissement and SIRET on the model' do
|
||||
champ.reload
|
||||
expect(champ.etablissement).to be_nil
|
||||
expect(champ.value).to be_empty
|
||||
it 'clears the etablissement on the model' do
|
||||
expect(champ.reload.etablissement).to be_nil
|
||||
end
|
||||
|
||||
it 'displays a “SIRET is invalid” error message' do
|
||||
|
@ -76,10 +72,8 @@ describe Champs::SiretController, type: :controller do
|
|||
|
||||
subject! { get :show, params: params, format: :turbo_stream }
|
||||
|
||||
it 'clears the etablissement and SIRET on the model' do
|
||||
champ.reload
|
||||
expect(champ.etablissement).to be_nil
|
||||
expect(champ.value).to be_empty
|
||||
it 'clears the etablissement on the model' do
|
||||
expect(champ.reload.etablissement).to be_nil
|
||||
end
|
||||
|
||||
it 'displays a “API is unavailable” error message' do
|
||||
|
@ -115,10 +109,8 @@ describe Champs::SiretController, type: :controller do
|
|||
|
||||
subject! { get :show, params: params, format: :turbo_stream }
|
||||
|
||||
it 'clears the etablissement and SIRET on the model' do
|
||||
champ.reload
|
||||
expect(champ.etablissement).to be_nil
|
||||
expect(champ.value).to be_empty
|
||||
it 'clears the etablissement on the model' do
|
||||
expect(champ.reload.etablissement).to be_nil
|
||||
end
|
||||
|
||||
it 'displays a “SIRET not found” error message' do
|
||||
|
|
|
@ -16,8 +16,6 @@ RSpec.describe SiretChampEtablissementFetchableConcern do
|
|||
subject(:fetch_etablissement!) { champ.fetch_etablissement!(siret, build_stubbed(:user)) }
|
||||
|
||||
shared_examples 'an error occured' do |error|
|
||||
it { expect { fetch_etablissement! }.to change { champ.reload.value }.to('') }
|
||||
|
||||
it { expect { fetch_etablissement! }.to change { champ.reload.etablissement }.to(nil) }
|
||||
|
||||
it { expect { fetch_etablissement! }.to change { Etablissement.count }.by(-1) }
|
||||
|
|
Loading…
Reference in a new issue