demarches-normaliennes/spec/components/instructeurs/column_picker_component_spec.rb

29 lines
1.1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
describe Instructeurs::ColumnPickerComponent, type: :component do
let(:component) { described_class.new(procedure:, procedure_presentation:) }
let(:procedure) { create(:procedure) }
2024-10-07 21:46:59 +02:00
let(:procedure_id) { procedure.id }
let(:instructeur) { create(:instructeur) }
let(:assign_to) { create(:assign_to, procedure: procedure, instructeur: instructeur) }
let(:procedure_presentation) { create(:procedure_presentation, assign_to: assign_to) }
2024-08-19 14:34:36 +02:00
describe "#displayable_columns_for_select" do
2024-10-07 21:46:59 +02:00
let(:default_user_email) { Column.new(procedure_id:, label: 'email', table: 'user', column: 'email') }
let(:excluded_displayable_field) { Column.new(procedure_id:, label: "label1", table: "table1", column: "column1", displayable: false) }
2024-10-07 16:57:54 +02:00
let(:email_column_id) { default_user_email.id }
2024-08-19 14:34:36 +02:00
subject { component.displayable_columns_for_select }
before do
2024-08-19 14:34:36 +02:00
allow(procedure).to receive(:columns).and_return([
default_user_email,
excluded_displayable_field
])
end
2024-10-07 21:46:59 +02:00
it { is_expected.to eq([[["email", email_column_id]], [email_column_id]]) }
end
end