Commit 96105e21 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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

parent 5ca17723
class ProjectObserver < ActiveRecord::Observer class ProjectObserver < ActiveRecord::Observer
def before_save(project) def before_save(project)
# Move repository if namespace changed # Move repository if namespace changed
if project.namespace_id_changed? if project.namespace_id_changed? and not project.new_record?
move_project(project) move_project(project)
end end
end end
......
...@@ -9,6 +9,12 @@ class UserObserver < ActiveRecord::Observer ...@@ -9,6 +9,12 @@ class UserObserver < ActiveRecord::Observer
log_info("User \"#{user.name}\" (#{user.email}) was removed") log_info("User \"#{user.name}\" (#{user.email}) was removed")
end end
def after_save user
if user.username_changed?
user.namespace.update_attributes(code: user.username)
end
end
protected protected
def log_info message def log_info message
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment