diff --git a/app/observers/project_observer.rb b/app/observers/project_observer.rb index ed503f3d11602d11daded4faa6e56977be295be4..16457e0ca05f9d17e6974755077ea2cca49c0901 100644 --- a/app/observers/project_observer.rb +++ b/app/observers/project_observer.rb @@ -1,7 +1,7 @@ class ProjectObserver < ActiveRecord::Observer def before_save(project) # Move repository if namespace changed - if project.namespace_id_changed? + if project.namespace_id_changed? and not project.new_record? move_project(project) end end diff --git a/app/observers/user_observer.rb b/app/observers/user_observer.rb index 654621f7e1c9b0be102221811b97c650d8a7bd95..3834123871c156db501285c5b900f382062eb1a6 100644 --- a/app/observers/user_observer.rb +++ b/app/observers/user_observer.rb @@ -9,6 +9,12 @@ class UserObserver < ActiveRecord::Observer log_info("User \"#{user.name}\" (#{user.email}) was removed") end + def after_save user + if user.username_changed? + user.namespace.update_attributes(code: user.username) + end + end + protected def log_info message