From 720a312b0092e911a27860715958920ddf2aff97 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 1 Aug 2024 18:54:50 +0200 Subject: [PATCH] fix(rnf): really normalize spaces Fix #10653 --- app/models/champs/rnf_champ.rb | 2 +- spec/models/champs/rnf_champ_spec.rb | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/models/champs/rnf_champ.rb b/app/models/champs/rnf_champ.rb index 67cc8407cb3..05e7dede799 100644 --- a/app/models/champs/rnf_champ.rb +++ b/app/models/champs/rnf_champ.rb @@ -2,7 +2,7 @@ class Champs::RNFChamp < Champ store_accessor :data, :title, :email, :phone, :createdAt, :updatedAt, :dissolvedAt, :address, :status def rnf_id - external_id&.gsub(/[:space:]/, '') + external_id&.gsub(/[[:space:]]/, '') end def value diff --git a/spec/models/champs/rnf_champ_spec.rb b/spec/models/champs/rnf_champ_spec.rb index bdd753f2aae..bd22eff4d41 100644 --- a/spec/models/champs/rnf_champ_spec.rb +++ b/spec/models/champs/rnf_champ_spec.rb @@ -7,7 +7,7 @@ describe 'fetch_external_data' do let(:url) { RNFService.new.send(:url) } let(:status) { 200 } - before { stub_request(:get, "#{url}/#{external_id}").to_return(body:, status:) } + before { stub_request(:get, "#{url}/075-FDD-00003-01").to_return(body:, status:) } subject { champ.fetch_external_data } @@ -51,20 +51,14 @@ context 'success (with space)' do let(:external_id) { '075-FDD- 00003-01 ' } it { - expect(subject.value!).to include({ - id: 3, - rnfId: '075-FDD-00003-01' - }) + expect(subject).to be_success } end context 'success (with tab)' do let(:external_id) { '075-FDD-0 0003-01 ' } it { - expect(subject.value!).to include({ - id: 3, - rnfId: '075-FDD-00003-01' - }) + expect(subject).to be_success } end