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;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,4 +19,8 @@
|
||||||
background-image: none; // remove DSFR underline
|
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);
|
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
|
.flex.align-center
|
||||||
- available_operations.each do |opt|
|
- 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]}
|
= 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}" }
|
%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
|
= body
|
||||||
|
|
|
@ -92,8 +92,8 @@ module Instructeurs
|
||||||
assign_exports
|
assign_exports
|
||||||
|
|
||||||
@batch_operations = BatchOperation.joins(:groupe_instructeurs)
|
@batch_operations = BatchOperation.joins(:groupe_instructeurs)
|
||||||
.where(groupe_instructeurs: current_instructeur.groupe_instructeurs.where(procedure_id: @procedure.id))
|
.where(groupe_instructeurs: current_instructeur.groupe_instructeurs.where(procedure_id: @procedure.id))
|
||||||
.distinct
|
.distinct
|
||||||
end
|
end
|
||||||
|
|
||||||
def deleted_dossiers
|
def deleted_dossiers
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { ApplicationController } from './application_controller';
|
import { ApplicationController } from './application_controller';
|
||||||
|
|
||||||
export class BatchOperationController extends ApplicationController {
|
export class BatchOperationController extends ApplicationController {
|
||||||
static targets = ['input', 'all', 'submit', 'form'];
|
static targets = ['form', 'input', 'submit'];
|
||||||
|
|
||||||
declare readonly submit: HTMLFormElement;
|
declare readonly formTarget: HTMLFormElement;
|
||||||
declare readonly submit: HTMLInputElement;
|
declare readonly submitTarget: HTMLInputElement;
|
||||||
declare readonly allTarget: HTMLInputElement;
|
|
||||||
declare readonly inputTargets: HTMLInputElement[];
|
declare readonly inputTargets: HTMLInputElement[];
|
||||||
|
|
||||||
connect() {
|
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>)
|
// 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, ...)
|
// 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
|
// so we intercept the form submit, and set the BatchOperation.operation by hand using the Event.submitter
|
||||||
interceptFormSubmit(event: Event) {
|
interceptFormSubmit(event: SubmitEvent) {
|
||||||
const { submitter } = event;
|
const submitter = event.submitter as HTMLInputElement;
|
||||||
|
|
||||||
submitter.setAttribute('value', submitter.dataset.submitterOperation);
|
submitter.setAttribute('value', submitter.dataset.submitterOperation || '');
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +31,9 @@ export class BatchOperationController extends ApplicationController {
|
||||||
}
|
}
|
||||||
|
|
||||||
onCheckAll(event: Event) {
|
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();
|
this.toggleSubmitButtonWhenNeeded();
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
@import '@gouvfr/dsfr/dist/component/link/link.css';
|
@import '@gouvfr/dsfr/dist/component/link/link.css';
|
||||||
@import '@gouvfr/dsfr/dist/component/form/form.css';
|
@import '@gouvfr/dsfr/dist/component/form/form.css';
|
||||||
@import '@gouvfr/dsfr/dist/component/button/button.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. */
|
/* Verify README of each component to insert them in the expected order. */
|
||||||
@import '@gouvfr/dsfr/dist/component/alert/alert.css';
|
@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))
|
= 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
|
%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?
|
- if @batch_operations.present?
|
||||||
- @batch_operations.each do |batch_operation|
|
- @batch_operations.each do |batch_operation|
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
.flex
|
.flex
|
||||||
.flex-grow= render batch_operation_component
|
.flex-grow= render batch_operation_component
|
||||||
.fr-table.fr-table--bordered
|
.fr-table.fr-table--bordered
|
||||||
%table
|
%table.dossiers-table
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
- if batch_operation_component.render?
|
- if batch_operation_component.render?
|
||||||
|
|
|
@ -5,8 +5,8 @@ RSpec.describe Dossiers::BatchOperationComponent, type: :component do
|
||||||
|
|
||||||
let(:component) do
|
let(:component) do
|
||||||
cmp = nil
|
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|
|
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)
|
cmp = described_class.new(statut: statut, procedure: create(:procedure))
|
||||||
end
|
end
|
||||||
cmp
|
cmp
|
||||||
end
|
end
|
||||||
|
@ -14,12 +14,11 @@ RSpec.describe Dossiers::BatchOperationComponent, type: :component do
|
||||||
subject { render_inline(component).to_html }
|
subject { render_inline(component).to_html }
|
||||||
context 'statut traite' do
|
context 'statut traite' do
|
||||||
let(:statut) { 'traites' }
|
let(:statut) { 'traites' }
|
||||||
it { is_expected.to have_selector('.fr-select-group') }
|
it { is_expected.to have_selector('input') }
|
||||||
it { is_expected.to have_selector('option', text: "Archiver") }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'statut tous' do
|
context 'statut tous' do
|
||||||
let(:statut) { 'tous' }
|
let(:statut) { 'tous' }
|
||||||
it { is_expected.not_to have_selector('.fr-select-group') }
|
it { is_expected.not_to have_selector('input') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -721,7 +721,6 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
expect(assigns(:is_dossier_in_batch_operation)).to eq(true)
|
expect(assigns(:is_dossier_in_batch_operation)).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#update_annotations" do
|
describe "#update_annotations" do
|
||||||
|
|
|
@ -6,8 +6,8 @@ FactoryBot.define do
|
||||||
|
|
||||||
trait :archiver do
|
trait :archiver do
|
||||||
operation { BatchOperation.operations.fetch(:archiver) }
|
operation { BatchOperation.operations.fetch(:archiver) }
|
||||||
after(:build) do |batch_operation, _evaluator|
|
after(:build) do |batch_operation, evaluator|
|
||||||
procedure = create(:simple_procedure, :published, instructeurs: [_evaluator.invalid_instructeur.presence || batch_operation.instructeur], administrateurs: [create(:administrateur)])
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur], administrateurs: [create(:administrateur)])
|
||||||
batch_operation.dossiers = [
|
batch_operation.dossiers = [
|
||||||
create(:dossier, :with_individual, :accepte, procedure: procedure),
|
create(:dossier, :with_individual, :accepte, procedure: procedure),
|
||||||
create(:dossier, :with_individual, :refuse, 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
|
context 'when it is the first job' do
|
||||||
it 'sets run_at at first' do
|
it 'sets run_at at first' do
|
||||||
run_at = 2.minutes.ago
|
expect { batch_operation.track_processed_dossier(false, dossier) }
|
||||||
Timecop.freeze(run_at) do
|
.to change { batch_operation.reload.run_at }
|
||||||
expect { batch_operation.track_processed_dossier(false, dossier) }
|
.from(nil)
|
||||||
.to change { batch_operation.reload.run_at }
|
.to(anything)
|
||||||
.from(nil)
|
|
||||||
.to(run_at)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,13 +100,10 @@ describe BatchOperation, type: :model do
|
||||||
|
|
||||||
context 'when it is the last job' do
|
context 'when it is the last job' do
|
||||||
it 'sets finished_at' do
|
it 'sets finished_at' do
|
||||||
finished_at = Time.zone.now
|
expect { batch_operation.track_processed_dossier(true, dossier) }
|
||||||
Timecop.freeze(finished_at) do
|
.to change { batch_operation.reload.finished_at }
|
||||||
expect { batch_operation.track_processed_dossier(true, dossier) }
|
.from(nil)
|
||||||
.to change { batch_operation.reload.finished_at }
|
.to(anything)
|
||||||
.from(nil)
|
|
||||||
.to(finished_at)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue