remove procedure from component signature

This commit is contained in:
simon lehericey 2024-10-25 13:51:19 +02:00
parent d421d41e16
commit 13356f26c3
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
5 changed files with 17 additions and 9 deletions

View file

@ -3,9 +3,9 @@
class Instructeurs::ColumnFilterComponent < ApplicationComponent
attr_reader :procedure, :procedure_presentation, :statut, :column
def initialize(procedure:, procedure_presentation:, statut:, column: nil)
@procedure = procedure
def initialize(procedure_presentation:, statut:, column: nil)
@procedure_presentation = procedure_presentation
@procedure = procedure_presentation.procedure
@statut = statut
@column = column
end

View file

@ -1,4 +1,7 @@
= form_with model: [:instructeur, @procedure_presentation], class: 'dropdown-form large', id: 'filter-component', data: { turbo: true, controller: 'autosubmit' } do
= form_with model: [:instructeur, @procedure_presentation],
class: 'dropdown-form large',
id: 'filter-component',
data: { turbo: true, controller: 'autosubmit' } do
= current_filter_tags
.fr-select-group

View file

@ -3,4 +3,4 @@
= t('views.instructeurs.dossiers.filters.title')
- menu.with_form do
= render Instructeurs::ColumnFilterComponent.new(procedure:, procedure_presentation:, statut:)
= render Instructeurs::ColumnFilterComponent.new(procedure_presentation:, statut:)

View file

@ -1,2 +1,2 @@
= turbo_stream.replace 'filter-component' do
= render Instructeurs::ColumnFilterComponent.new(procedure: @procedure, procedure_presentation: @procedure_presentation, statut: @statut, column: @column)
= render Instructeurs::ColumnFilterComponent.new(procedure_presentation: @procedure_presentation, statut: @statut, column: @column)

View file

@ -1,12 +1,17 @@
# frozen_string_literal: true
describe Instructeurs::ColumnFilterComponent, type: :component do
let(:component) { described_class.new(procedure:, procedure_presentation:, statut:, column:) }
let(:component) { described_class.new(procedure_presentation:, statut:, column:) }
let(:instructeur) { create(:instructeur) }
let(:procedure) { create(:procedure, instructeurs: [instructeur]) }
let(:procedure) { create(:procedure) }
let(:procedure_id) { procedure.id }
let(:procedure_presentation) { nil }
let(:procedure_presentation) do
groupe_instructeur = procedure.defaut_groupe_instructeur
assign_to = create(:assign_to, instructeur:, groupe_instructeur:)
assign_to.procedure_presentation_or_default_and_errors.first
end
let(:statut) { nil }
let(:column) { nil }
@ -19,7 +24,7 @@ describe Instructeurs::ColumnFilterComponent, type: :component do
let(:non_filterable_column) { Column.new(procedure_id:, label: 'depose_since', table: 'self', column: 'depose_since', filterable: false) }
let(:mocked_columns) { [filterable_column, non_filterable_column] }
before { allow(procedure).to receive(:columns).and_return(mocked_columns) }
before { allow_any_instance_of(Procedure).to receive(:columns).and_return(mocked_columns) }
subject { component.filterable_columns_options }