Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-02-08 23:54:33 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-02-09 00:36:23 +0300
commit4d40c3c30a945d28487dfe08c0985ccb636ce3bc (patch)
treeabfd4455ccfc2bd022a6e39bdaaf63823c7fbc93 /app/models/route.rb
parentd01cd84e69999677b5cb0d4f03d140f33cfdc0f7 (diff)
Fix route rename descendants if route.name is blank
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/route.rb')
-rw-r--r--app/models/route.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/app/models/route.rb b/app/models/route.rb
index 4eec3e73d5b..73574a6206b 100644
--- a/app/models/route.rb
+++ b/app/models/route.rb
@@ -15,14 +15,19 @@ class Route < ActiveRecord::Base
descendants = Route.where('path LIKE ?', "#{path_was}/%")
descendants.each do |route|
- attributes = {
- path: route.path.sub(path_was, path),
- name: route.name.sub(name_was, name)
- }
+ attributes = {}
+
+ if path_changed? && route.path.present?
+ attributes[:path] = route.path.sub(path_was, path)
+ end
+
+ if name_changed? && route.name.present?
+ attributes[:name] = route.name.sub(name_was, name)
+ end
# Note that update_columns skips validation and callbacks.
# We need this to avoid recursive call of rename_descendants method
- route.update_columns(attributes)
+ route.update_columns(attributes) unless attributes.empty?
end
end
end