diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-06-11 14:22:33 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-06-11 14:22:33 +0300 |
commit | c058aaf7dcc0f05ea3583f5ba04ff483e6cf65ed (patch) | |
tree | cb6c81643cd197bf6830efa8a79b8b42b83c71b4 /app | |
parent | 6eb045fc98f02a54b5db37ff2a43b008fe971158 (diff) | |
download | gitlab-ce-c058aaf7dcc0f05ea3583f5ba04ff483e6cf65ed.tar.gz |
Keep namespace name/username synced with user
Diffstat (limited to 'app')
-rw-r--r-- | app/observers/user_observer.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/app/observers/user_observer.rb b/app/observers/user_observer.rb index 6bb3c471d0c..e969405a598 100644 --- a/app/observers/user_observer.rb +++ b/app/observers/user_observer.rb @@ -10,12 +10,11 @@ class UserObserver < BaseObserver end def after_save user - if user.username_changed? - if user.namespace - user.namespace.update_attributes(path: user.username) - else - user.create_namespace!(path: user.username, name: user.username) - end + # Ensure user has namespace + user.create_namespace!(path: user.username, name: user.username) unless user.namespace + + if user.username_changed? || user.name_changed? + user.namespace.update_attributes(path: user.username, name: user.name) end end end |