diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /app/models/route.rb | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) | |
download | gitlab-ce-983a0bba5d2a042c4a3bbb22432ec192c7501d82.tar.gz |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'app/models/route.rb')
-rw-r--r-- | app/models/route.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/route.rb b/app/models/route.rb index 91ea2966013..63a0461807b 100644 --- a/app/models/route.rb +++ b/app/models/route.rb @@ -2,9 +2,9 @@ class Route < ApplicationRecord include CaseSensitivity + include Gitlab::SQL::Pattern belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations - validates :source, presence: true validates :path, @@ -19,6 +19,8 @@ class Route < ApplicationRecord after_update :rename_descendants scope :inside_path, -> (path) { where('routes.path LIKE ?', "#{sanitize_sql_like(path)}/%") } + scope :for_routable, -> (routable) { where(source: routable) } + scope :sort_by_path_length, -> { order('LENGTH(routes.path)', :path) } def rename_descendants return unless saved_change_to_path? || saved_change_to_name? |