Update namespace if user changed username. Dont move project if new record
This commit is contained in:
parent
5ca1772385
commit
96105e214f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue