clean(spec): rubocopify / fix specs
This commit is contained in:
parent
5875f9b572
commit
b0ae2e8a0f
13 changed files with 38 additions and 39 deletions
|
@ -49,3 +49,4 @@ fieldset {
|
|||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,4 +19,8 @@
|
|||
background-image: none; // remove DSFR underline
|
||||
}
|
||||
}
|
||||
|
||||
.fr-btns-group .fr-btn {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
.force-table-100{
|
||||
|
||||
.force-table-100 {
|
||||
width: calc(100vw);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
= form_for(BatchOperation.new, url: Rails.application.routes.url_helpers.instructeur_batch_operations_path(procedure_id: procedure.id), method: :post, id: dom_id(BatchOperation.new), html: { class: 'flex justify-end' }, data: { "batch-operation-target" => "form"}) do |form|
|
||||
= form_for(BatchOperation.new, url: instructeur_batch_operations_path(procedure_id: procedure.id), method: :post, id: dom_id(BatchOperation.new), html: { class: 'flex justify-end' }, data: { "batch-operation-target" => "form"}) do |form|
|
||||
.flex.align-center
|
||||
- available_operations.each do |opt|
|
||||
= form.submit opt[0], class: "fr-btn", disabled: :disabled, name: "#{form.object_name}[operation]", data: { "batch-operation-target" => "submit", "submitter-operation" => opt[1]}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
%div{ class: "fr-alert fr-alert--#{state}" }
|
||||
%h3.fr-alert__title= "#{prefix_for_state}#{title}"
|
||||
= content_tag(heading_level, class: 'fr-alert__title') do
|
||||
= "#{prefix_for_state}#{title}"
|
||||
= body
|
||||
|
|
|
@ -92,8 +92,8 @@ module Instructeurs
|
|||
assign_exports
|
||||
|
||||
@batch_operations = BatchOperation.joins(:groupe_instructeurs)
|
||||
.where(groupe_instructeurs: current_instructeur.groupe_instructeurs.where(procedure_id: @procedure.id))
|
||||
.distinct
|
||||
.where(groupe_instructeurs: current_instructeur.groupe_instructeurs.where(procedure_id: @procedure.id))
|
||||
.distinct
|
||||
end
|
||||
|
||||
def deleted_dossiers
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { ApplicationController } from './application_controller';
|
||||
|
||||
export class BatchOperationController extends ApplicationController {
|
||||
static targets = ['input', 'all', 'submit', 'form'];
|
||||
static targets = ['form', 'input', 'submit'];
|
||||
|
||||
declare readonly submit: HTMLFormElement;
|
||||
declare readonly submit: HTMLInputElement;
|
||||
declare readonly allTarget: HTMLInputElement;
|
||||
declare readonly formTarget: HTMLFormElement;
|
||||
declare readonly submitTarget: HTMLInputElement;
|
||||
declare readonly inputTargets: HTMLInputElement[];
|
||||
|
||||
connect() {
|
||||
|
@ -18,10 +17,10 @@ export class BatchOperationController extends ApplicationController {
|
|||
// DSFR recommends a <input type="submit" /> or <button type="submit" /> a form (not a <select>)
|
||||
// but we have many actions on the same form (archive all, accept all, ...)
|
||||
// so we intercept the form submit, and set the BatchOperation.operation by hand using the Event.submitter
|
||||
interceptFormSubmit(event: Event) {
|
||||
const { submitter } = event;
|
||||
interceptFormSubmit(event: SubmitEvent) {
|
||||
const submitter = event.submitter as HTMLInputElement;
|
||||
|
||||
submitter.setAttribute('value', submitter.dataset.submitterOperation);
|
||||
submitter.setAttribute('value', submitter.dataset.submitterOperation || '');
|
||||
|
||||
return event;
|
||||
}
|
||||
|
@ -32,7 +31,9 @@ export class BatchOperationController extends ApplicationController {
|
|||
}
|
||||
|
||||
onCheckAll(event: Event) {
|
||||
this.inputTargets.forEach((e) => (e.checked = event.target.checked));
|
||||
const target = event.target as HTMLInputElement;
|
||||
|
||||
this.inputTargets.forEach((e) => (e.checked = target.checked));
|
||||
this.toggleSubmitButtonWhenNeeded();
|
||||
return event;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
@import '@gouvfr/dsfr/dist/component/link/link.css';
|
||||
@import '@gouvfr/dsfr/dist/component/form/form.css';
|
||||
@import '@gouvfr/dsfr/dist/component/button/button.css';
|
||||
@import '@gouvfr/dsfr/dist/component/select/select.css';
|
||||
|
||||
/* Verify README of each component to insert them in the expected order. */
|
||||
@import '@gouvfr/dsfr/dist/component/alert/alert.css';
|
||||
|
|
|
@ -68,8 +68,8 @@
|
|||
= render Dossiers::ExportComponent.new(procedure: @procedure, exports: @exports, statut: @statut, count: @dossiers_count, export_url: method(:download_export_instructeur_procedure_path))
|
||||
%hr.fr-mt-5v
|
||||
|
||||
%div{ data: { controller: 'batch-operation' } }
|
||||
- batch_operation_component = Dossiers::BatchOperationComponent.new(statut: @statut, procedure: @procedure)
|
||||
- batch_operation_component = Dossiers::BatchOperationComponent.new(statut: @statut, procedure: @procedure)
|
||||
%div{ data: batch_operation_component.render? ? { controller: 'batch-operation' } : {} }
|
||||
|
||||
- if @batch_operations.present?
|
||||
- @batch_operations.each do |batch_operation|
|
||||
|
@ -78,7 +78,7 @@
|
|||
.flex
|
||||
.flex-grow= render batch_operation_component
|
||||
.fr-table.fr-table--bordered
|
||||
%table
|
||||
%table.dossiers-table
|
||||
%thead
|
||||
%tr
|
||||
- if batch_operation_component.render?
|
||||
|
|
|
@ -5,8 +5,8 @@ RSpec.describe Dossiers::BatchOperationComponent, type: :component do
|
|||
|
||||
let(:component) do
|
||||
cmp = nil
|
||||
form_for(BatchOperation.new, url: Rails.application.routes.url_helpers.instructeur_batch_operations_path(procedure_id: 1), method: :post, data: { controller: 'batch-operation' }) do |form|
|
||||
cmp = described_class.new(statut: statut, form: form)
|
||||
form_for(BatchOperation.new, url: Rails.application.routes.url_helpers.instructeur_batch_operations_path(procedure_id: 1), method: :post, data: { controller: 'batch-operation' }) do |_form|
|
||||
cmp = described_class.new(statut: statut, procedure: create(:procedure))
|
||||
end
|
||||
cmp
|
||||
end
|
||||
|
@ -14,12 +14,11 @@ RSpec.describe Dossiers::BatchOperationComponent, type: :component do
|
|||
subject { render_inline(component).to_html }
|
||||
context 'statut traite' do
|
||||
let(:statut) { 'traites' }
|
||||
it { is_expected.to have_selector('.fr-select-group') }
|
||||
it { is_expected.to have_selector('option', text: "Archiver") }
|
||||
it { is_expected.to have_selector('input') }
|
||||
end
|
||||
|
||||
context 'statut tous' do
|
||||
let(:statut) { 'tous' }
|
||||
it { is_expected.not_to have_selector('.fr-select-group') }
|
||||
it { is_expected.not_to have_selector('input') }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -721,7 +721,6 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
expect(assigns(:is_dossier_in_batch_operation)).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#update_annotations" do
|
||||
|
|
|
@ -6,8 +6,8 @@ FactoryBot.define do
|
|||
|
||||
trait :archiver do
|
||||
operation { BatchOperation.operations.fetch(:archiver) }
|
||||
after(:build) do |batch_operation, _evaluator|
|
||||
procedure = create(:simple_procedure, :published, instructeurs: [_evaluator.invalid_instructeur.presence || batch_operation.instructeur], administrateurs: [create(:administrateur)])
|
||||
after(:build) do |batch_operation, evaluator|
|
||||
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur], administrateurs: [create(:administrateur)])
|
||||
batch_operation.dossiers = [
|
||||
create(:dossier, :with_individual, :accepte, procedure: procedure),
|
||||
create(:dossier, :with_individual, :refuse, procedure: procedure),
|
||||
|
|
|
@ -83,13 +83,10 @@ describe BatchOperation, type: :model do
|
|||
|
||||
context 'when it is the first job' do
|
||||
it 'sets run_at at first' do
|
||||
run_at = 2.minutes.ago
|
||||
Timecop.freeze(run_at) do
|
||||
expect { batch_operation.track_processed_dossier(false, dossier) }
|
||||
.to change { batch_operation.reload.run_at }
|
||||
.from(nil)
|
||||
.to(run_at)
|
||||
end
|
||||
expect { batch_operation.track_processed_dossier(false, dossier) }
|
||||
.to change { batch_operation.reload.run_at }
|
||||
.from(nil)
|
||||
.to(anything)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -103,13 +100,10 @@ describe BatchOperation, type: :model do
|
|||
|
||||
context 'when it is the last job' do
|
||||
it 'sets finished_at' do
|
||||
finished_at = Time.zone.now
|
||||
Timecop.freeze(finished_at) do
|
||||
expect { batch_operation.track_processed_dossier(true, dossier) }
|
||||
.to change { batch_operation.reload.finished_at }
|
||||
.from(nil)
|
||||
.to(finished_at)
|
||||
end
|
||||
expect { batch_operation.track_processed_dossier(true, dossier) }
|
||||
.to change { batch_operation.reload.finished_at }
|
||||
.from(nil)
|
||||
.to(anything)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue