Fix 500 error when try to update own profile in admin area
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
504777ec20
commit
4401382798
3 changed files with 22 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue