-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10708 from mfo/US/format-rna
ETQ tech je souhaite que les champs RNA ne puissent pas contenir d'espace sans quoi nos appels d'API remontent un URI::InvalidURIError
- Loading branch information
Showing
5 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
app/components/editable_champ/rna_component/rna_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
= @form.text_field(:value, input_opts( id: @champ.input_id, aria: { describedby: @champ.describedby_id }, data: { controller: 'turbo-input', turbo_input_load_on_connect_value: @champ.prefilled? && @champ.value.present? && @champ.data.blank?, turbo_input_url_value: update_path }, required: @champ.required?, pattern: "W[0-9]{9}", class: "width-33-desktop", maxlength: 10)) | ||
= @form.text_field(:value, input_opts( id: @champ.input_id, aria: { describedby: @champ.describedby_id }, data: { controller: 'turbo-input format', format: 'deleteSpace', turbo_input_load_on_connect_value: @champ.prefilled? && @champ.value.present? && @champ.data.blank?, turbo_input_url_value: update_path }, required: @champ.required?, pattern: "W[0-9A-Z]{9}", class: "width-33-desktop", maxlength: 10)) | ||
|
||
.rna-info{ id: dom_id(@champ, :rna_info) } | ||
= render 'shared/champs/rna/association', champ: @champ, error: nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Maintenance | ||
class NormalizeRNAValuesTask < MaintenanceTasks::Task | ||
def collection | ||
Champs::RNAChamp.where.not(value: nil) | ||
end | ||
|
||
def process(element) | ||
if /\s/.match?(element.value) | ||
element.update_column(:value, element.value.gsub(/\s+/, '')) | ||
end | ||
end | ||
|
||
def count | ||
# to costly | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
module Maintenance | ||
RSpec.describe NormalizeRNAValuesTask do | ||
describe "#process" do | ||
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :rna }]) } | ||
let(:dossier) { create(:dossier, :with_populated_champs, procedure:) } | ||
let(:element) { dossier.champs.first } | ||
subject(:process) { described_class.process(element) } | ||
let(:error_value) { "999 0 999" } | ||
it "removes extra spaces" do | ||
element.update_column(:value, error_value) | ||
expect { subject }.to change { element.reload.value }.from(error_value).to("9990999") | ||
end | ||
end | ||
end | ||
end |