fix: allow previous id with ->
to work
This commit is contained in:
parent
aa0b7f53ef
commit
38e998c279
2 changed files with 20 additions and 1 deletions
|
@ -12,6 +12,13 @@ module ColumnsConcern
|
|||
column = columns.find { _1.h_id == h_id } if h_id.present?
|
||||
column = columns.find { _1.label == label } if label.present?
|
||||
|
||||
# TODO: to remove after linked_drop_down column column_id migration
|
||||
if column.nil? && h_id.is_a?(Hash) && h_id[:column_id].present?
|
||||
h_id[:column_id].gsub!('->', '.')
|
||||
|
||||
column = columns.find { _1.h_id == h_id }
|
||||
end
|
||||
|
||||
raise ActiveRecord::RecordNotFound.new("Column: unable to find h_id: #{h_id} or label: #{label} for procedure_id #{id}") if column.nil?
|
||||
|
||||
column
|
||||
|
|
|
@ -4,7 +4,8 @@ describe ColumnsConcern do
|
|||
let(:procedure_id) { procedure.id }
|
||||
|
||||
describe '#find_column' do
|
||||
let(:procedure) { build(:procedure) }
|
||||
let(:types_de_champ_public) { [{ type: :linked_drop_down_list, libelle: 'linked' }] }
|
||||
let(:procedure) { create(:procedure, types_de_champ_public:) }
|
||||
let(:notifications_column) { procedure.notifications_column }
|
||||
|
||||
it do
|
||||
|
@ -16,6 +17,17 @@ describe ColumnsConcern do
|
|||
|
||||
unknwon = 'unknown'
|
||||
expect { procedure.find_column(h_id: unknwon) }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
|
||||
value_column = procedure.find_column(label: 'linked')
|
||||
|
||||
procedure_id = procedure.id
|
||||
linked_tdc = procedure.active_revision.types_de_champ
|
||||
.find { _1.type_champ == 'linked_drop_down_list' }
|
||||
|
||||
column_id = "type_de_champ/#{linked_tdc.stable_id}->value"
|
||||
|
||||
h_id = { procedure_id:, column_id: }
|
||||
expect(procedure.find_column(h_id:)).to eq(value_column)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue