Commit 44013827988cb18d7c3b504f001256388da71abf
1 parent
504777ec
Exists in
spb-stable
and in
3 other branches
Fix 500 error when try to update own profile in admin area
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
22 additions
and
1 deletions
Show diff stats
app/controllers/admin/users_controller.rb
| ... | ... | @@ -68,7 +68,9 @@ class Admin::UsersController < Admin::ApplicationController |
| 68 | 68 | params[:user].delete(:password_confirmation) |
| 69 | 69 | end |
| 70 | 70 | |
| 71 | - user.admin = (admin && admin.to_i > 0) | |
| 71 | + if admin.present? | |
| 72 | + user.admin = !admin.to_i.zero? | |
| 73 | + end | |
| 72 | 74 | |
| 73 | 75 | respond_to do |format| |
| 74 | 76 | if user.update_attributes(params[:user], as: :admin) | ... | ... |
features/admin/users.feature
| ... | ... | @@ -14,3 +14,9 @@ Feature: Admin Users |
| 14 | 14 | And Click save |
| 15 | 15 | Then See username error message |
| 16 | 16 | And Not changed form action url |
| 17 | + | |
| 18 | + Scenario: Edit my user attributes | |
| 19 | + Given I visit admin users page | |
| 20 | + And click edit on my user | |
| 21 | + When I submit modified user | |
| 22 | + Then I see user attributes changed | ... | ... |
features/steps/admin/admin_users.rb
| ... | ... | @@ -31,4 +31,17 @@ class AdminUsers < Spinach::FeatureSteps |
| 31 | 31 | And 'Not changed form action url' do |
| 32 | 32 | page.should have_selector %(form[action="/admin/users/#{@user.username}"]) |
| 33 | 33 | end |
| 34 | + | |
| 35 | + step 'I submit modified user' do | |
| 36 | + check :user_can_create_group | |
| 37 | + click_button 'Save' | |
| 38 | + end | |
| 39 | + | |
| 40 | + step 'I see user attributes changed' do | |
| 41 | + page.should have_content 'Can create groups: Yes' | |
| 42 | + end | |
| 43 | + | |
| 44 | + step 'click edit on my user' do | |
| 45 | + find("#edit_user_#{current_user.id}").click | |
| 46 | + end | |
| 34 | 47 | end | ... | ... |