Commit b9e2228c authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'fj-avoid-loading-namespace' into 'master'

Avoid loading project namespace for id

See merge request gitlab-org/gitlab!71051
parents 07956fbc c5b9c6b5
...@@ -28,7 +28,7 @@ module Routing ...@@ -28,7 +28,7 @@ module Routing
when 'groups' when 'groups'
"/namespace:#{group.id}" "/namespace:#{group.id}"
when 'projects' when 'projects'
"/namespace:#{project.namespace.id}/project:#{project.id}" "/namespace:#{project.namespace_id}/project:#{project.id}"
when 'root' when 'root'
'' ''
else else
...@@ -44,7 +44,7 @@ module Routing ...@@ -44,7 +44,7 @@ module Routing
masked_url = "#{request.protocol}#{request.host_with_port}" masked_url = "#{request.protocol}#{request.host_with_port}"
if request_params.has_key?(:project_id) if request_params.has_key?(:project_id)
masked_url += "/namespace:#{project.namespace.id}/project:#{project.id}/-/#{namespace_type}" masked_url += "/namespace:#{project.namespace_id}/project:#{project.id}/-/#{namespace_type}"
end end
if request_params.has_key?(:id) if request_params.has_key?(:id)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module Projects module Projects
class OverwriteProjectService < BaseService class OverwriteProjectService < BaseService
def execute(source_project) def execute(source_project)
return unless source_project && source_project.namespace == @project.namespace return unless source_project && source_project.namespace_id == @project.namespace_id
start_time = ::Gitlab::Metrics::System.monotonic_time start_time = ::Gitlab::Metrics::System.monotonic_time
...@@ -40,7 +40,7 @@ module Projects ...@@ -40,7 +40,7 @@ module Projects
duration = ::Gitlab::Metrics::System.monotonic_time - start_time duration = ::Gitlab::Metrics::System.monotonic_time - start_time
Gitlab::AppJsonLogger.info(class: self.class.name, Gitlab::AppJsonLogger.info(class: self.class.name,
namespace_id: source_project.namespace.id, namespace_id: source_project.namespace_id,
project_id: source_project.id, project_id: source_project.id,
duration_s: duration.to_f, duration_s: duration.to_f,
error: exception.class.name) error: exception.class.name)
......
...@@ -35,7 +35,7 @@ module Security ...@@ -35,7 +35,7 @@ module Security
security_policy_target_project_id: project.id, security_policy_target_project_id: project.id,
name: "#{project.name} - Security policy project", name: "#{project.name} - Security policy project",
description: "This project is automatically generated to manage security policies for the project.", description: "This project is automatically generated to manage security policies for the project.",
namespace_id: project.namespace.id, namespace_id: project.namespace_id,
initialize_with_readme: true, initialize_with_readme: true,
container_registry_enabled: false, container_registry_enabled: false,
packages_enabled: false, packages_enabled: false,
......
...@@ -7,7 +7,7 @@ module Gitlab ...@@ -7,7 +7,7 @@ module Gitlab
grouped_items = issuables.group_by do |issuable| grouped_items = issuables.group_by do |issuable|
if issuable.project.id == project.id if issuable.project.id == project.id
:project_ref :project_ref
elsif issuable.project.namespace.id == project.namespace.id elsif issuable.project.namespace_id == project.namespace_id
:namespace_ref :namespace_ref
else else
:full_ref :full_ref
......
...@@ -6,6 +6,7 @@ RSpec.describe ::Routing::PseudonymizationHelper do ...@@ -6,6 +6,7 @@ RSpec.describe ::Routing::PseudonymizationHelper do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:subgroup) { create(:group, parent: group) } let_it_be(:subgroup) { create(:group, parent: group) }
let_it_be(:project) { create(:project, group: group) } let_it_be(:project) { create(:project, group: group) }
let_it_be(:subproject) { create(:project, group: subgroup) }
let_it_be(:issue) { create(:issue, project: project) } let_it_be(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
...@@ -56,16 +57,16 @@ RSpec.describe ::Routing::PseudonymizationHelper do ...@@ -56,16 +57,16 @@ RSpec.describe ::Routing::PseudonymizationHelper do
end end
context 'with controller for groups with subgroups and project' do context 'with controller for groups with subgroups and project' do
let(:masked_url) { "http://test.host/namespace:#{subgroup.id}/project:#{project.id}"} let(:masked_url) { "http://test.host/namespace:#{subgroup.id}/project:#{subproject.id}"}
before do before do
allow(helper).to receive(:group).and_return(subgroup) allow(helper).to receive(:group).and_return(subgroup)
allow(helper.project).to receive(:namespace).and_return(subgroup) allow(helper).to receive(:project).and_return(subproject)
allow(Rails.application.routes).to receive(:recognize_path).and_return({ allow(Rails.application.routes).to receive(:recognize_path).and_return({
controller: 'projects', controller: 'projects',
action: 'show', action: 'show',
namespace_id: subgroup.name, namespace_id: subgroup.name,
id: project.name id: subproject.name
}) })
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment