summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-26 15:38:44 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-26 15:38:44 +0000
commitcf129d6f34c098f5e1b248bd52bb5db72aecfd13 (patch)
treedbeec19871a23a9d51f2e1794aca1ed97f5010b1
parent4ef836923a85d470508f3bdd6b4f30cac2333086 (diff)
parent98f4665eaf8d352988467217b6b91732e9f8cced (diff)
downloadgitlab-ce-cf129d6f34c098f5e1b248bd52bb5db72aecfd13.tar.gz
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
-rw-r--r--app/controllers/admin/users_controller.rb4
-rw-r--r--app/controllers/users_controller.rb1
-rw-r--r--app/views/users/show.html.haml2
-rw-r--r--features/admin/users.feature6
-rw-r--r--features/steps/admin/admin_users.rb13
5 files changed, 24 insertions, 2 deletions
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index bdbb9a354b4..5b06af79d5a 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -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)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index e86601a439e..28da6da4403 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -11,6 +11,7 @@ class UsersController < ApplicationController
end
@events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20)
@title = @user.name
+ @groups = @projects.map(&:group).compact.uniq
end
def determine_layout
diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml
index 98210af1e3d..fda4793270f 100644
--- a/app/views/users/show.html.haml
+++ b/app/views/users/show.html.haml
@@ -14,7 +14,7 @@
%small member since #{@user.created_at.stamp("Nov 12, 2031")}
.clearfix
%h4 Groups:
- = render 'groups', groups: @user.groups
+ = render 'groups', groups: @groups
%hr
%h4 User Activity:
= render @events
diff --git a/features/admin/users.feature b/features/admin/users.feature
index 7f503cf9235..ce9f32f50d9 100644
--- a/features/admin/users.feature
+++ b/features/admin/users.feature
@@ -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
diff --git a/features/steps/admin/admin_users.rb b/features/steps/admin/admin_users.rb
index 33c1344eaeb..659008dd875 100644
--- a/features/steps/admin/admin_users.rb
+++ b/features/steps/admin/admin_users.rb
@@ -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