Commit dbd3680f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix 500 error when try to update own profile in admin area

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 4ef83692
......@@ -68,7 +68,9 @@ class Admin::UsersController < Admin::ApplicationController
params[:user].delete(:password_confirmation)
end
user.admin = (admin && admin.to_i > 0)
if admin.present?
user.admin = !admin.to_i.zero?
end
respond_to do |format|
if user.update_attributes(params[:user], as: :admin)
......
......@@ -14,3 +14,9 @@ Feature: Admin Users
And Click save
Then See username error message
And Not changed form action url
Scenario: Edit my user attributes
Given I visit admin users page
And click edit on my user
When I submit modified user
Then I see user attributes changed
......@@ -31,4 +31,17 @@ class AdminUsers < Spinach::FeatureSteps
And 'Not changed form action url' do
page.should have_selector %(form[action="/admin/users/#{@user.username}"])
end
step 'I submit modified user' do
check :user_can_create_group
click_button 'Save'
end
step 'I see user attributes changed' do
page.should have_content 'Can create groups: Yes'
end
step 'click edit on my user' do
find("#edit_user_#{current_user.id}").click
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment