Commit d344d1b3 authored by Stan Hu's avatar Stan Hu

Use path instead of a URL for accessing approval settings

Hosts using a non-standard configuration may have a different
hostname/port/scheme than what may be configured on the GitLab
server. While expose_url should generate a proper URL, there are cases
where it may not work. Since we don't need the full URL, we can use the
relative path.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/61558
parent c79f3fe5
......@@ -7,37 +7,37 @@ module EE
def approvals_path
if expose_mr_approval_path?
expose_url(approvals_project_merge_request_path(project, merge_request))
expose_path(approvals_project_merge_request_path(project, merge_request))
end
end
def api_approvals_path
if expose_mr_approval_path?
expose_url(api_v4_projects_merge_requests_approvals_path(id: project.id, merge_request_iid: merge_request.iid))
expose_path(api_v4_projects_merge_requests_approvals_path(id: project.id, merge_request_iid: merge_request.iid))
end
end
def api_approval_settings_path
if expose_mr_approval_path?
expose_url(api_v4_projects_merge_requests_approval_settings_path(id: project.id, merge_request_iid: merge_request.iid))
expose_path(api_v4_projects_merge_requests_approval_settings_path(id: project.id, merge_request_iid: merge_request.iid))
end
end
def api_project_approval_settings_path
if approval_feature_available?
expose_url(api_v4_projects_approval_settings_path(id: project.id))
expose_path(api_v4_projects_approval_settings_path(id: project.id))
end
end
def api_approve_path
if expose_mr_approval_path?
expose_url(api_v4_projects_merge_requests_approve_path(id: project.id, merge_request_iid: merge_request.iid))
expose_path(api_v4_projects_merge_requests_approve_path(id: project.id, merge_request_iid: merge_request.iid))
end
end
def api_unapprove_path
if expose_mr_approval_path?
expose_url(api_v4_projects_merge_requests_unapprove_path(id: project.id, merge_request_iid: merge_request.iid))
expose_path(api_v4_projects_merge_requests_unapprove_path(id: project.id, merge_request_iid: merge_request.iid))
end
end
......
......@@ -2,9 +2,9 @@
= form.label :approver_ids, class: 'label-bold' do
= _("Add approvers")
#js-mr-approvals-settings{ data: { 'project_id': @project.id,
'project_path': expose_url(api_v4_projects_path(id: @project.id)),
'settings_path': expose_url(api_v4_projects_approval_settings_path(id: @project.id)),
'rules_path': expose_url(api_v4_projects_approval_settings_rules_path(id: @project.id)),
'project_path': expose_path(api_v4_projects_path(id: @project.id)),
'settings_path': expose_path(api_v4_projects_approval_settings_path(id: @project.id)),
'rules_path': expose_path(api_v4_projects_approval_settings_rules_path(id: @project.id)),
'allow_multi_rule': @project.multiple_approval_rules_available?.to_s } }
.text-center.prepend-top-default
= sprite_icon('spinner', size: 24, css_class: 'gl-spinner')
---
title: Use path instead of a URL for accessing approval settings
merge_request: 12414
author:
type: fixed
......@@ -34,7 +34,7 @@ describe MergeRequestPresenter do
it_behaves_like 'is nil when needed'
it { is_expected.to eq(expose_url("/#{merge_request.project.full_path}/merge_requests/#{merge_request.iid}/approvals")) }
it { is_expected.to eq(expose_path("/#{merge_request.project.full_path}/merge_requests/#{merge_request.iid}/approvals")) }
end
describe '#api_approvals_path' do
......@@ -42,7 +42,7 @@ describe MergeRequestPresenter do
it_behaves_like 'is nil when needed'
it { is_expected.to eq(expose_url("/api/v4/projects/#{merge_request.project.id}/merge_requests/#{merge_request.iid}/approvals")) }
it { is_expected.to eq(expose_path("/api/v4/projects/#{merge_request.project.id}/merge_requests/#{merge_request.iid}/approvals")) }
end
describe '#api_approval_settings_path' do
......@@ -50,13 +50,13 @@ describe MergeRequestPresenter do
it_behaves_like 'is nil when needed'
it { is_expected.to eq(expose_url("/api/v4/projects/#{merge_request.project.id}/merge_requests/#{merge_request.iid}/approval_settings")) }
it { is_expected.to eq(expose_path("/api/v4/projects/#{merge_request.project.id}/merge_requests/#{merge_request.iid}/approval_settings")) }
end
describe '#api_project_approval_settings_path' do
subject { described_class.new(merge_request, current_user: user).api_project_approval_settings_path }
it { is_expected.to eq(expose_url("/api/v4/projects/#{merge_request.project.id}/approval_settings")) }
it { is_expected.to eq(expose_path("/api/v4/projects/#{merge_request.project.id}/approval_settings")) }
context "when approvals not available" do
let(:approval_feature_available) { false }
......@@ -70,7 +70,7 @@ describe MergeRequestPresenter do
it_behaves_like 'is nil when needed'
it { is_expected.to eq(expose_url("/api/v4/projects/#{merge_request.project.id}/merge_requests/#{merge_request.iid}/approve")) }
it { is_expected.to eq(expose_path("/api/v4/projects/#{merge_request.project.id}/merge_requests/#{merge_request.iid}/approve")) }
end
describe '#api_unapprove_path' do
......@@ -78,7 +78,7 @@ describe MergeRequestPresenter do
it_behaves_like 'is nil when needed'
it { is_expected.to eq(expose_url("/api/v4/projects/#{merge_request.project.id}/merge_requests/#{merge_request.iid}/unapprove")) }
it { is_expected.to eq(expose_path("/api/v4/projects/#{merge_request.project.id}/merge_requests/#{merge_request.iid}/unapprove")) }
end
describe '#approvers_left' do
......
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