diff --git a/app/dashboards/administrateur_dashboard.rb b/app/dashboards/administrateur_dashboard.rb index ba6f91072..ead5ef9f7 100644 --- a/app/dashboards/administrateur_dashboard.rb +++ b/app/dashboards/administrateur_dashboard.rb @@ -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 diff --git a/app/dashboards/instructeur_dashboard.rb b/app/dashboards/instructeur_dashboard.rb index e88052331..f61b858db 100644 --- a/app/dashboards/instructeur_dashboard.rb +++ b/app/dashboards/instructeur_dashboard.rb @@ -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 diff --git a/app/models/administrateur.rb b/app/models/administrateur.rb index 8082325d3..0b982aabf 100644 --- a/app/models/administrateur.rb +++ b/app/models/administrateur.rb @@ -92,4 +92,8 @@ class Administrateur < ApplicationRecord destroy end + + # required to display feature flags field in manager + def features + end end diff --git a/app/models/instructeur.rb b/app/models/instructeur.rb index bb55fe36a..f3cc6dff7 100644 --- a/app/models/instructeur.rb +++ b/app/models/instructeur.rb @@ -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) diff --git a/spec/controllers/manager/administrateurs_controller_spec.rb b/spec/controllers/manager/administrateurs_controller_spec.rb index b1504511a..1261c49b8 100644 --- a/spec/controllers/manager/administrateurs_controller_spec.rb +++ b/spec/controllers/manager/administrateurs_controller_spec.rb @@ -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 diff --git a/spec/controllers/manager/instructeurs_controller_spec.rb b/spec/controllers/manager/instructeurs_controller_spec.rb index 3a0164d4b..ef44aa706 100644 --- a/spec/controllers/manager/instructeurs_controller_spec.rb +++ b/spec/controllers/manager/instructeurs_controller_spec.rb @@ -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 } } diff --git a/spec/controllers/manager/users_controller_spec.rb b/spec/controllers/manager/users_controller_spec.rb index 4aacf54a1..58a71972a 100644 --- a/spec/controllers/manager/users_controller_spec.rb +++ b/spec/controllers/manager/users_controller_spec.rb @@ -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') }