commit
cac0041819
3 changed files with 13 additions and 6 deletions
|
|
@ -20,8 +20,15 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
message = ''
|
||||||
|
if params[:user] && !params[:user][:email].nil?
|
||||||
|
if (new_email = params[:user][:email]) != @user.email
|
||||||
|
message = " Confirmation email sent to #{new_email}. The new email needs to be confirmed before it can be used."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if @user.update_attributes(params[:user])
|
if @user.update_attributes(params[:user])
|
||||||
redirect_to admin_users_path, notice: "Updated #{@user.name} (#{@user.email})!"
|
redirect_to admin_users_path, notice: "Updated #{@user.name} (#{@user.email})!" + message
|
||||||
else
|
else
|
||||||
redirect_to admin_users_path, alert: "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}."
|
redirect_to admin_users_path, alert: "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}."
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
%li
|
%li
|
||||||
= link_to(edit_user_path(current_user.id)) do
|
= link_to(edit_user_path(current_user.id)) do
|
||||||
%span.fa.fa-user
|
%span.fa.fa-user
|
||||||
Edit Profil
|
Edit Profile
|
||||||
-if @conference and @conference.id
|
-if @conference and @conference.id
|
||||||
%li
|
%li
|
||||||
= link_to(conference_proposal_index_path(@conference.short_title)) do
|
= link_to(conference_proposal_index_path(@conference.short_title)) do
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ describe Admin::UsersController do
|
||||||
end
|
end
|
||||||
describe 'GET #index' do
|
describe 'GET #index' do
|
||||||
it 'populates an array of users' do
|
it 'populates an array of users' do
|
||||||
user1 = create(:user, email: 'gopesh.7500@gmail.com')
|
user1 = create(:user, email: 'user1@email.osem')
|
||||||
user2 = create(:user, email: 'gopesh_750@gmail.com')
|
user2 = create(:user, email: 'user2@email.osem')
|
||||||
get :index
|
get :index
|
||||||
expect(assigns(:users)).to match_array([user, admin, user1, user2])
|
expect(assigns(:users)).to match_array([user, admin, user1, user2])
|
||||||
end
|
end
|
||||||
|
|
@ -26,8 +26,8 @@ describe Admin::UsersController do
|
||||||
it 'changes @users attributes' do
|
it 'changes @users attributes' do
|
||||||
patch :update, id: user.id
|
patch :update, id: user.id
|
||||||
expect(build(
|
expect(build(
|
||||||
:user, email: 'example@incoherent.de', id: user.id).email).
|
:user, email: 'new@email.osem', id: user.id).email).
|
||||||
to eq('example@incoherent.de')
|
to eq('new@email.osem')
|
||||||
end
|
end
|
||||||
it 'redirects to the updated user' do
|
it 'redirects to the updated user' do
|
||||||
patch :update, id: user.id
|
patch :update, id: user.id
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue