Commit 9cfdefdc authored by Fernando's avatar Fernando

Fix broken license policy page

* Due to
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/22465

landing after changes in
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24831

there was a mismatch in variable names being passed from
the controller.

* MR fixe the variable names and updates unit tests

Fix robot cop offenses

Add changelog
parent bb3ca457
---
title: Fix broken license policy page
merge_request: 25300
author:
type: fixed
......@@ -85,9 +85,19 @@ module Projects
value.in?(%w[true 1])
end
def write_license_policies_endpoint
if can?(current_user, :admin_software_license_policy, @project)
api_v4_projects_managed_licenses_path(id: @project.id)
else
''
end
end
def licenses_app_data
{
endpoint: project_licenses_path(project, detected: true, format: :json),
project_licenses_endpoint: project_licenses_path(@project, detected: true, format: :json),
read_license_policies_endpoint: api_v4_projects_managed_licenses_path(id: @project.id),
write_license_policies_endpoint: write_license_policies_endpoint,
documentation_path: help_page_path('user/application_security/license_compliance/index'),
empty_state_svg_path: helpers.image_path('illustrations/Dependency-list-empty-state.svg')
}
......
- breadcrumb_title _('License Compliance')
- page_title _('License Compliance')
#js-licenses-app{ data: licenses_app_data }
#js-licenses-app{ data: @licenses_app_data }
......@@ -14,13 +14,14 @@ describe Projects::LicensesController do
end
context 'with authorized user' do
context 'when feature is available' do
before do
project.add_reporter(user)
stub_licensed_features(license_management: true)
end
context 'when feature is available' do
context 'with reporter' do
before do
stub_licensed_features(license_management: true)
project.add_reporter(user)
end
it 'responds to an HTML request' do
......@@ -28,7 +29,9 @@ describe Projects::LicensesController do
expect(response).to have_gitlab_http_status(:ok)
licenses_app_data = assigns(:licenses_app_data)
expect(licenses_app_data[:endpoint]).to eql(controller.helpers.project_licenses_path(project, detected: true, format: :json))
expect(licenses_app_data[:project_licenses_endpoint]).to eql(controller.helpers.project_licenses_path(project, detected: true, format: :json))
expect(licenses_app_data[:read_license_policies_endpoint]).to eql(controller.helpers.api_v4_projects_managed_licenses_path(id: project.id))
expect(licenses_app_data[:write_license_policies_endpoint]).to eql('')
expect(licenses_app_data[:documentation_path]).to eql(help_page_path('user/application_security/license_compliance/index'))
expect(licenses_app_data[:empty_state_svg_path]).to eql(controller.helpers.image_path('illustrations/Dependency-list-empty-state.svg'))
end
......@@ -245,6 +248,25 @@ describe Projects::LicensesController do
end
end
context 'with maintainer' do
before do
project.add_maintainer(user)
end
it 'responds to an HTML request' do
get :index, params: params
expect(response).to have_gitlab_http_status(:ok)
licenses_app_data = assigns(:licenses_app_data)
expect(licenses_app_data[:project_licenses_endpoint]).to eql(controller.helpers.project_licenses_path(project, detected: true, format: :json))
expect(licenses_app_data[:read_license_policies_endpoint]).to eql(controller.helpers.api_v4_projects_managed_licenses_path(id: project.id))
expect(licenses_app_data[:write_license_policies_endpoint]).to eql(controller.helpers.api_v4_projects_managed_licenses_path(id: project.id))
expect(licenses_app_data[:documentation_path]).to eql(help_page_path('user/application_security/license_compliance/index'))
expect(licenses_app_data[:empty_state_svg_path]).to eql(controller.helpers.image_path('illustrations/Dependency-list-empty-state.svg'))
end
end
end
context 'when feature is not available' do
before do
get_licenses
......
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