Merge pull request #4801 from betagouv/4797-impossible-ajouter-administrateur-dans-manager

- permet d'ajouter de nouveau un administrateur depuis le manager
- permet de nouveau de rechercher un administrateur depuis le manager
This commit is contained in:
krichtof 2020-02-19 15:36:38 +01:00 committed by GitHub
commit bcd92f5956
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 7 deletions

View file

@ -16,7 +16,7 @@ class AdministrateurDashboard < Administrate::BaseDashboard
registration_state: Field::String.with_options(searchable: false),
current_sign_in_at: Field::DateTime,
features: FeaturesField,
email: Field::Email
email: Field::Email.with_options(searchable: false)
}.freeze
# COLLECTION_ATTRIBUTES

View file

@ -0,0 +1,13 @@
= form_for([namespace, Administrateur.new(user: User.new)], html: { class: "form" }) do |f|
- if page.resource.errors.any?
#error_explanation
%h2
= t("administrate.form.errors", pluralized_errors: pluralize(page.resource.errors.count, t("administrate.form.error")), resource_name: display_resource_name(page.resource_name))
%ul
- page.resource.errors.full_messages.each do |message|
%li.flash-error= message
- page.attributes.each do |attribute|
%div{ :class => "field-unit field-unit--#{attribute.html_class}" }
= render_field attribute, f: f
.form-actions
= f.submit

View file

@ -1,14 +1,22 @@
describe Manager::AdministrateursController, type: :controller do
let(:administration) { create(:administration) }
before do
sign_in administration
end
describe 'GET #new' do
render_views
it 'displays form to create a new admin' do
get :new
expect(response).to be_success
end
end
describe 'POST #create' do
let(:email) { 'plop@plop.com' }
let(:password) { 'démarches-simplifiées-pwd' }
before do
sign_in administration
end
subject { post :create, params: { administrateur: { email: email } } }
context 'when email and password are correct' do
@ -35,8 +43,6 @@ describe Manager::AdministrateursController, type: :controller do
describe '#delete' do
let!(:admin) { create(:administrateur) }
before { sign_in administration }
subject { delete :delete, params: { id: admin.id } }
it 'deletes the admin' do
@ -45,4 +51,14 @@ describe Manager::AdministrateursController, type: :controller do
expect(Administrateur.find_by(id: admin.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 }
expect(response).to be_success
end
end
end