diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2016-12-13 13:04:11 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2016-12-13 13:04:11 +0000 |
commit | bd219711b99a31025614bf5715b35a140baf50b6 (patch) | |
tree | 65d34de4922d86cab50ebd103a817adf250e482b /app | |
parent | 0139896b370a56619b29e08ba8b5d0da091443b1 (diff) | |
parent | 3e0b8e000f088c24493e993139f8af1be2e14de1 (diff) | |
download | gitlab-ce-bd219711b99a31025614bf5715b35a140baf50b6.tar.gz |
Merge branch 'dz-nested-group-improvements-2' into 'master'
Minor improvements to nested groups code
See merge request !8011
Diffstat (limited to 'app')
-rw-r--r-- | app/models/concerns/routable.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb index d36bb9da296..1108a64c59e 100644 --- a/app/models/concerns/routable.rb +++ b/app/models/concerns/routable.rb @@ -7,6 +7,7 @@ module Routable has_one :route, as: :source, autosave: true, dependent: :destroy validates_associated :route + validates :route, presence: true before_validation :update_route_path, if: :full_path_changed? end @@ -28,17 +29,17 @@ module Routable order_sql = "(CASE WHEN #{binary} routes.path = #{connection.quote(path)} THEN 0 ELSE 1 END)" - where_paths_in([path]).reorder(order_sql).take + where_full_path_in([path]).reorder(order_sql).take end # Builds a relation to find multiple objects by their full paths. # # Usage: # - # Klass.where_paths_in(%w{gitlab-org/gitlab-ce gitlab-org/gitlab-ee}) + # Klass.where_full_path_in(%w{gitlab-org/gitlab-ce gitlab-org/gitlab-ee}) # # Returns an ActiveRecord::Relation. - def where_paths_in(paths) + def where_full_path_in(paths) wheres = [] cast_lower = Gitlab::Database.postgresql? |