From e1c245af51e294c84552cff8021342e7ae493b8a Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Fri, 5 May 2017 10:48:01 -0700 Subject: [PATCH] Resolve discussions --- app/controllers/projects/application_controller.rb | 11 +++++------ app/models/route.rb | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 25232fc9457..b4b0dfc3eb8 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -21,13 +21,12 @@ class Projects::ApplicationController < ApplicationController end def project - @project ||= find_routable!(Project, - File.join(params[:namespace_id], params[:project_id] || params[:id]), - extra_authorization_proc: project_not_being_deleted?) - end + return @project if @project - def project_not_being_deleted? - ->(project) { !project.pending_delete? } + path = File.join(params[:namespace_id], params[:project_id] || params[:id]) + auth_proc = ->(project) { !project.pending_delete? } + + @project = find_routable!(Project, path, extra_authorization_proc: auth_proc) end def repository diff --git a/app/models/route.rb b/app/models/route.rb index 3d798ce937b..b34cce9077a 100644 --- a/app/models/route.rb +++ b/app/models/route.rb @@ -16,7 +16,7 @@ class Route < ActiveRecord::Base scope :direct_descendant_routes, -> (path) { where('routes.path LIKE ? AND routes.path NOT LIKE ?', "#{sanitize_sql_like(path)}/%", "#{sanitize_sql_like(path)}/%/%") } def rename_direct_descendant_routes - return if !path_changed? && !name_changed? + return unless path_changed? || name_changed? direct_descendant_routes = self.class.direct_descendant_routes(path_was)