Update namespace if user changed username. Dont move project if new record

This commit is contained in:
Dmitriy Zaporozhets 2012-11-23 06:39:09 +03:00
parent 5ca1772385
commit 96105e214f
2 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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