Remove non-existant columns from manager dashboards

This commit is contained in:
Paul Chavard 2020-03-26 16:17:07 +01:00
parent 953ebfe45a
commit c763679b54
7 changed files with 48 additions and 12 deletions

View file

@ -14,7 +14,6 @@ class AdministrateurDashboard < Administrate::BaseDashboard
updated_at: Field::DateTime,
procedures: Field::HasMany.with_options(limit: 20),
registration_state: Field::String.with_options(searchable: false),
current_sign_in_at: Field::DateTime,
features: FeaturesField,
email: Field::Email.with_options(searchable: false)
}.freeze
@ -39,7 +38,6 @@ class AdministrateurDashboard < Administrate::BaseDashboard
:created_at,
:updated_at,
:registration_state,
:current_sign_in_at,
:features,
:procedures
].freeze

View file

@ -12,7 +12,6 @@ class InstructeurDashboard < Administrate::BaseDashboard
user: Field::HasOne.with_options(searchable: true, searchable_field: 'email'),
created_at: Field::DateTime,
updated_at: Field::DateTime,
current_sign_in_at: Field::DateTime,
dossiers: Field::HasMany,
procedures: Field::HasMany,
features: FeaturesField
@ -35,7 +34,6 @@ class InstructeurDashboard < Administrate::BaseDashboard
:dossiers,
:id,
:user,
:current_sign_in_at,
:created_at,
:features
].freeze

View file

@ -92,4 +92,8 @@ class Administrateur < ApplicationRecord
destroy
end
# required to display feature flags field in manager
def features
end
end

View file

@ -191,6 +191,10 @@ class Instructeur < ApplicationRecord
user.administrateur.nil? && procedures.all? { |p| p.defaut_groupe_instructeur.instructeurs.count > 1 }
end
# required to display feature flags field in manager
def features
end
private
def annotations_hash(demande, annotations_privees, avis, messagerie)

View file

@ -1,10 +1,21 @@
describe Manager::AdministrateursController, type: :controller do
let(:administration) { create(:administration) }
let(:administrateur) { create(:administrateur) }
before do
sign_in administration
end
describe '#show' do
render_views
before do
get :show, params: { id: administrateur.id }
end
it { expect(response.body).to include(administrateur.email) }
end
describe 'GET #new' do
render_views
it 'displays form to create a new admin' do
@ -41,23 +52,20 @@ describe Manager::AdministrateursController, type: :controller do
end
describe '#delete' do
let!(:admin) { create(:administrateur) }
subject { delete :delete, params: { id: admin.id } }
subject { delete :delete, params: { id: administrateur.id } }
it 'deletes the admin' do
subject
expect(Administrateur.find_by(id: admin.id)).to be_nil
expect(Administrateur.find_by(id: administrateur.id)).to be_nil
end
end
describe '#index' do
render_views
let(:admin) { create(:administrateur) }
it 'searches admin by email' do
get :index, params: { search: admin.email }
get :index, params: { search: administrateur.email }
expect(response).to be_success
end
end

View file

@ -1,9 +1,19 @@
describe Manager::InstructeursController, type: :controller do
let(:administration) { create(:administration) }
let(:instructeur) { create(:instructeur) }
describe '#show' do
render_views
before do
sign_in(administration)
get :show, params: { id: instructeur.id }
end
it { expect(response.body).to include(instructeur.email) }
end
describe '#delete' do
let!(:instructeur) { create(:instructeur) }
before { sign_in administration }
subject { delete :delete, params: { id: instructeur.id } }

View file

@ -1,6 +1,20 @@
describe Manager::UsersController, type: :controller do
let(:administration) { create(:administration) }
describe '#show' do
render_views
let(:administration) { create(:administration) }
let(:user) { create(:user) }
before do
sign_in(administration)
get :show, params: { id: user.id }
end
it { expect(response.body).to include(user.email) }
end
describe '#update' do
let!(:user) { create(:user, email: 'ancien.email@domaine.fr') }