tech(rubocopify): ... just clean up ...

This commit is contained in:
Martin 2022-07-21 15:27:21 +02:00 committed by mfo
parent 5e8210b8f8
commit d1297bc1f5
5 changed files with 14 additions and 19 deletions

View file

@ -6,7 +6,6 @@ module Instructeurs
:instructeur
end
def ensure_not_super_admin!
if is_super_admin_through_assign_tos_as_manager?
redirect_back fallback_location: root_url, alert: "Interdit aux super admins", status: 403
@ -15,13 +14,11 @@ module Instructeurs
def is_super_admin_through_assign_tos_as_manager?
current_instructeur.assign_to
.where(instructeur: current_instructeur,
.where(instructeur: current_instructeur,
groupe_instructeur: current_instructeur.groupe_instructeurs.where(procedure_id: @procedure.id),
manager: true)
.count
.positive?
.count
.positive?
end
end
end

View file

@ -1,6 +1,7 @@
module Instructeurs
class ProceduresController < InstructeurController
before_action :ensure_ownership!, except: [:index]
before_action :ensure_not_super_admin!, only: [:download_export]
ITEMS_PER_PAGE = 25

View file

@ -26,9 +26,9 @@
# last_champ_updated_at :datetime
# last_commentaire_updated_at :datetime
# motivation :text
# private_search_terms :text
# private_search_terms :string
# processed_at :datetime
# search_terms :text
# search_terms :string
# state :string
# termine_close_to_expiration_notice_sent_at :datetime
# created_at :datetime

View file

@ -79,7 +79,6 @@ describe Administrateurs::ExportsController, type: :controller do
expect(response).to have_http_status(:forbidden)
end
end
end
end
end

View file

@ -7,10 +7,10 @@ describe Instructeurs::ArchivesController, type: :controller do
let!(:assign_to) { create(:assign_to, instructeur: instructeur, groupe_instructeur: build(:groupe_instructeur), manager: manager) }
let(:gi2) { create(:groupe_instructeur) }
before do
before do
sign_in(instructeur.user)
end
after { Timecop.return }
end
after { Timecop.return }
describe '#index' do
before do
@ -19,11 +19,10 @@ describe Instructeurs::ArchivesController, type: :controller do
create_dossier_for_month(procedure1, 2021, 2)
Timecop.freeze(Time.zone.local(2021, 3, 5))
end
subject{get :index, params: { procedure_id: procedure1.id }}
subject { get :index, params: { procedure_id: procedure1.id } }
context 'signed in not as manager' do
let(:manager){ false }
let(:manager) { false }
it { is_expected.to have_http_status(:success) }
it 'assigns archives' do
@ -33,7 +32,7 @@ describe Instructeurs::ArchivesController, type: :controller do
end
context 'signed in as manager' do
let(:manager){ true }
let(:manager) { true }
before do
sign_in(instructeur.user)
@ -52,7 +51,7 @@ describe Instructeurs::ArchivesController, type: :controller do
let(:date_month) { Date.strptime(month, "%Y-%m") }
context 'signed in not as manager' do
let(:manager){ false }
let(:manager) { false }
it "performs archive creation job" do
expect { subject }.to have_enqueued_job(ArchiveCreationJob).with(procedure1, an_instance_of(Archive), instructeur)
@ -61,11 +60,10 @@ describe Instructeurs::ArchivesController, type: :controller do
end
context 'signed in as manager' do
let(:manager){ true }
let(:manager) { true }
it { is_expected.to have_http_status(:forbidden) }
end
end
private