Commit cf129d6f34c098f5e1b248bd52bb5db72aecfd13
Merge branch '6-6-3-patch' into '6-6-stable'
6.6.3 Patch Fixes 500 error when try to edit own user via admin area
Showing
5 changed files
with
24 additions
and
2 deletions
Show diff stats
app/controllers/admin/users_controller.rb
@@ -68,7 +68,9 @@ class Admin::UsersController < Admin::ApplicationController | @@ -68,7 +68,9 @@ class Admin::UsersController < Admin::ApplicationController | ||
68 | params[:user].delete(:password_confirmation) | 68 | params[:user].delete(:password_confirmation) |
69 | end | 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 | respond_to do |format| | 75 | respond_to do |format| |
74 | if user.update_attributes(params[:user], as: :admin) | 76 | if user.update_attributes(params[:user], as: :admin) |
app/controllers/users_controller.rb
@@ -11,6 +11,7 @@ class UsersController < ApplicationController | @@ -11,6 +11,7 @@ class UsersController < ApplicationController | ||
11 | end | 11 | end |
12 | @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) | 12 | @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) |
13 | @title = @user.name | 13 | @title = @user.name |
14 | + @groups = @projects.map(&:group).compact.uniq | ||
14 | end | 15 | end |
15 | 16 | ||
16 | def determine_layout | 17 | def determine_layout |
app/views/users/show.html.haml
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | %small member since #{@user.created_at.stamp("Nov 12, 2031")} | 14 | %small member since #{@user.created_at.stamp("Nov 12, 2031")} |
15 | .clearfix | 15 | .clearfix |
16 | %h4 Groups: | 16 | %h4 Groups: |
17 | - = render 'groups', groups: @user.groups | 17 | + = render 'groups', groups: @groups |
18 | %hr | 18 | %hr |
19 | %h4 User Activity: | 19 | %h4 User Activity: |
20 | = render @events | 20 | = render @events |
features/admin/users.feature
@@ -14,3 +14,9 @@ Feature: Admin Users | @@ -14,3 +14,9 @@ Feature: Admin Users | ||
14 | And Click save | 14 | And Click save |
15 | Then See username error message | 15 | Then See username error message |
16 | And Not changed form action url | 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,4 +31,17 @@ class AdminUsers < Spinach::FeatureSteps | ||
31 | And 'Not changed form action url' do | 31 | And 'Not changed form action url' do |
32 | page.should have_selector %(form[action="/admin/users/#{@user.username}"]) | 32 | page.should have_selector %(form[action="/admin/users/#{@user.username}"]) |
33 | end | 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 | end | 47 | end |