summaryrefslogtreecommitdiff
path: root/app/models/route.rb
diff options
context:
space:
mode:
authorJasper Maes <jaspermaes.jm@gmail.com>2019-01-15 22:05:36 +0100
committerHeinrich Lee Yu <heinrich@gitlab.com>2019-04-23 08:31:23 +0800
commit624a1cdab4da67c7b363602aa1178d0e6ff63475 (patch)
tree09892175f885c4c5f6725314b25a61280395efcb /app/models/route.rb
parent46bdbc5d776a0438366426e0ef48911123311744 (diff)
downloadgitlab-ce-624a1cdab4da67c7b363602aa1178d0e6ff63475.tar.gz
Upgrade Rails to 5.1.6.1
Model.new.attributes now also returns encrypted attributes.
Diffstat (limited to 'app/models/route.rb')
-rw-r--r--app/models/route.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/models/route.rb b/app/models/route.rb
index 7e3db54d4fe..91ea2966013 100644
--- a/app/models/route.rb
+++ b/app/models/route.rb
@@ -14,26 +14,26 @@ class Route < ApplicationRecord
before_validation :delete_conflicting_orphaned_routes
after_create :delete_conflicting_redirects
- after_update :delete_conflicting_redirects, if: :path_changed?
+ after_update :delete_conflicting_redirects, if: :saved_change_to_path?
after_update :create_redirect_for_old_path
after_update :rename_descendants
scope :inside_path, -> (path) { where('routes.path LIKE ?', "#{sanitize_sql_like(path)}/%") }
def rename_descendants
- return unless path_changed? || name_changed?
+ return unless saved_change_to_path? || saved_change_to_name?
- descendant_routes = self.class.inside_path(path_was)
+ descendant_routes = self.class.inside_path(path_before_last_save)
descendant_routes.each do |route|
attributes = {}
- if path_changed? && route.path.present?
- attributes[:path] = route.path.sub(path_was, path)
+ if saved_change_to_path? && route.path.present?
+ attributes[:path] = route.path.sub(path_before_last_save, path)
end
- if name_changed? && name_was.present? && route.name.present?
- attributes[:name] = route.name.sub(name_was, name)
+ if saved_change_to_name? && name_before_last_save.present? && route.name.present?
+ attributes[:name] = route.name.sub(name_before_last_save, name)
end
if attributes.present?
@@ -65,7 +65,7 @@ class Route < ApplicationRecord
private
def create_redirect_for_old_path
- create_redirect(path_was) if path_changed?
+ create_redirect(path_before_last_save) if saved_change_to_path?
end
def delete_conflicting_orphaned_routes