ProcedureRevision#compare_type_de_champ: fix bug comparaison character_limit chaine vide vs nil
This commit is contained in:
parent
3c5749e45a
commit
4f62590b7a
2 changed files with 24 additions and 1 deletions
|
@ -440,7 +440,7 @@ class ProcedureRevision < ApplicationRecord
|
||||||
to_type_de_champ.filename_for_attachement(:notice_explicative))
|
to_type_de_champ.filename_for_attachement(:notice_explicative))
|
||||||
end
|
end
|
||||||
elsif to_type_de_champ.textarea?
|
elsif to_type_de_champ.textarea?
|
||||||
if from_type_de_champ.character_limit != to_type_de_champ.character_limit
|
if from_type_de_champ.character_limit.presence != to_type_de_champ.character_limit.presence
|
||||||
changes << ProcedureRevisionChange::UpdateChamp.new(from_type_de_champ,
|
changes << ProcedureRevisionChange::UpdateChamp.new(from_type_de_champ,
|
||||||
:character_limit,
|
:character_limit,
|
||||||
from_type_de_champ.character_limit,
|
from_type_de_champ.character_limit,
|
||||||
|
|
|
@ -537,6 +537,29 @@ describe ProcedureRevision do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when a type de champ is transformed into a text_area with no character limit' do
|
||||||
|
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :text }]) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
updated_tdc = new_draft.find_and_ensure_exclusive_use(first_tdc.stable_id)
|
||||||
|
updated_tdc.update(type_champ: :textarea, options: { "character_limit" => "" })
|
||||||
|
end
|
||||||
|
|
||||||
|
it do
|
||||||
|
is_expected.to eq([
|
||||||
|
{
|
||||||
|
op: :update,
|
||||||
|
attribute: :type_champ,
|
||||||
|
label: first_tdc.libelle,
|
||||||
|
private: false,
|
||||||
|
from: "text",
|
||||||
|
to: "textarea",
|
||||||
|
stable_id: first_tdc.stable_id
|
||||||
|
}
|
||||||
|
])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when a type de champ is moved' do
|
context 'when a type de champ is moved' do
|
||||||
let(:procedure) { create(:procedure, types_de_champ_public: Array.new(3) { { type: :text } }) }
|
let(:procedure) { create(:procedure, types_de_champ_public: Array.new(3) { { type: :text } }) }
|
||||||
let(:new_draft_second_tdc) { new_draft.types_de_champ_public.second }
|
let(:new_draft_second_tdc) { new_draft.types_de_champ_public.second }
|
||||||
|
|
Loading…
Add table
Reference in a new issue