summaryrefslogtreecommitdiff
path: root/app/models/namespace.rb
diff options
context:
space:
mode:
authorHeinrich Lee Yu <heinrich@gitlab.com>2019-04-23 17:30:18 +0800
committerHeinrich Lee Yu <heinrich@gitlab.com>2019-04-30 15:24:25 +0800
commitfc22626f453f64409ad5b2967cdec541dbcc041d (patch)
tree9686c1c160af34db2038c241ab7f0b665f1c51a0 /app/models/namespace.rb
parenta2543ee29a97f61f960994d473291c7224c50c3d (diff)
downloadgitlab-ce-fc22626f453f64409ad5b2967cdec541dbcc041d.tar.gz
Remove deprecated uses of attribute_changed?9932-fix-deprecated-attribute_changed-ce
Prepares us for upgrade to Rails 5.2
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb28
1 files changed, 16 insertions, 12 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 7228aab2c2e..168f6bedd63 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -63,7 +63,7 @@ class Namespace < ApplicationRecord
# Legacy Storage specific hooks
- after_update :move_dir, if: :path_or_parent_changed?
+ after_update :move_dir, if: :saved_change_to_path_or_parent?
before_destroy(prepend: true) { prepare_for_destroy }
after_destroy :rm_dir
@@ -144,7 +144,7 @@ class Namespace < ApplicationRecord
def send_update_instructions
projects.each do |project|
- project.send_move_instructions("#{full_path_was}/#{project.path}")
+ project.send_move_instructions("#{full_path_before_last_save}/#{project.path}")
end
end
@@ -229,10 +229,6 @@ class Namespace < ApplicationRecord
[owner_id]
end
- def parent_changed?
- parent_id_changed?
- end
-
# Includes projects from this namespace and projects from all subgroups
# that belongs to this namespace
def all_projects
@@ -262,12 +258,12 @@ class Namespace < ApplicationRecord
false
end
- def full_path_was
- if parent_id_was.nil?
- path_was
+ def full_path_before_last_save
+ if parent_id_before_last_save.nil?
+ path_before_last_save
else
- previous_parent = Group.find_by(id: parent_id_was)
- previous_parent.full_path + '/' + path_was
+ previous_parent = Group.find_by(id: parent_id_before_last_save)
+ previous_parent.full_path + '/' + path_before_last_save
end
end
@@ -293,7 +289,15 @@ class Namespace < ApplicationRecord
private
- def path_or_parent_changed?
+ def parent_changed?
+ parent_id_changed?
+ end
+
+ def saved_change_to_parent?
+ saved_change_to_parent_id?
+ end
+
+ def saved_change_to_path_or_parent?
saved_change_to_path? || saved_change_to_parent_id?
end