Refactor DAST profiles show view

This moves the dataset out of the DAST profiles show view into a
dedicated helper. This should make things tidier and easier to test.
parent c6598605
# frozen_string_literal: true
module Projects::Security::DastProfilesHelper
def dast_profiles_list_data(project)
{
'new_dast_saved_scan_path' => new_project_on_demand_scan_path(project),
'new_dast_site_profile_path' => new_project_security_configuration_dast_scans_dast_site_profile_path(project),
'new_dast_scanner_profile_path' => new_project_security_configuration_dast_scans_dast_scanner_profile_path(project),
'project_full_path' => project.path_with_namespace
}
end
end
......@@ -2,7 +2,4 @@
- breadcrumb_title s_('DastProfiles|Manage DAST scans')
- page_title s_('DastProfiles|Manage DAST scans')
.js-dast-profiles{ data: { new_dast_saved_scan_path: new_project_on_demand_scan_path(@project),
new_dast_site_profile_path: new_project_security_configuration_dast_scans_dast_site_profile_path(@project),
new_dast_scanner_profile_path: new_project_security_configuration_dast_scans_dast_scanner_profile_path(@project),
project_full_path: @project.path_with_namespace } }
.js-dast-profiles{ data: dast_profiles_list_data(@project) }
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::Security::DastProfilesHelper do
describe '#dast_profiles_list_data' do
let(:project) { create(:project) }
it 'returns proper data' do
expect(helper.dast_profiles_list_data(project)).to match(
{
'new_dast_saved_scan_path' => new_project_on_demand_scan_path(project),
'new_dast_site_profile_path' => new_project_security_configuration_dast_scans_dast_site_profile_path(project),
'new_dast_scanner_profile_path' => new_project_security_configuration_dast_scans_dast_scanner_profile_path(project),
'project_full_path' => project.path_with_namespace
}
)
end
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