Commit c058aaf7dcc0f05ea3583f5ba04ff483e6cf65ed

Authored by Dmitriy Zaporozhets
1 parent 6eb045fc

Keep namespace name/username synced with user

Showing 1 changed file with 5 additions and 6 deletions   Show diff stats
app/observers/user_observer.rb
... ... @@ -10,12 +10,11 @@ class UserObserver < BaseObserver
10 10 end
11 11  
12 12 def after_save user
13   - if user.username_changed?
14   - if user.namespace
15   - user.namespace.update_attributes(path: user.username)
16   - else
17   - user.create_namespace!(path: user.username, name: user.username)
18   - end
  13 + # Ensure user has namespace
  14 + user.create_namespace!(path: user.username, name: user.username) unless user.namespace
  15 +
  16 + if user.username_changed? || user.name_changed?
  17 + user.namespace.update_attributes(path: user.username, name: user.name)
19 18 end
20 19 end
21 20 end
... ...