Rewrite assertions with hardcoded values

Rewrites DAST profiles and on-demand scans helpers specs to use
hardcoded values instead of calling the same methods as the helpers
themselves.
parent 704631f5
......@@ -4,20 +4,29 @@ require 'spec_helper'
RSpec.describe Projects::OnDemandScansHelper do
describe '#on_demand_scans_data' do
let(:project) { create(:project) }
let_it_be(:project) { create(:project) }
let_it_be(:default_branch) { 'default-branch' }
let_it_be(:path_with_namespace) { 'foo/bar' }
let_it_be(:timezones) { [{ identifier: "Europe/Paris" }] }
before do
allow(project).to receive(:default_branch).and_return(default_branch)
allow(project).to receive(:path_with_namespace).and_return(path_with_namespace)
allow(helper).to receive(:timezone_data).with(format: :full).and_return(timezones)
end
it 'returns proper data' do
expect(helper.on_demand_scans_data(project)).to match(
'help-page-path' => "/help/user/application_security/dast/index#on-demand-scans",
'empty-state-svg-path' => match_asset_path('/assets/illustrations/empty-state/ondemand-scan-empty.svg'),
'default-branch' => project.default_branch,
'project-path' => project.path_with_namespace,
'profiles-library-path' => project_security_configuration_dast_scans_path(project),
'scanner-profiles-library-path' => project_security_configuration_dast_scans_path(project, anchor: 'scanner-profiles'),
'site-profiles-library-path' => project_security_configuration_dast_scans_path(project, anchor: 'site-profiles'),
'new-scanner-profile-path' => new_project_security_configuration_dast_scans_dast_scanner_profile_path(project),
'new-site-profile-path' => new_project_security_configuration_dast_scans_dast_site_profile_path(project),
'timezones' => helper.timezone_data(format: :full).to_json
'default-branch' => default_branch,
'project-path' => path_with_namespace,
'profiles-library-path' => "/#{project.full_path}/-/security/configuration/dast_scans",
'scanner-profiles-library-path' => "/#{project.full_path}/-/security/configuration/dast_scans#scanner-profiles",
'site-profiles-library-path' => "/#{project.full_path}/-/security/configuration/dast_scans#site-profiles",
'new-scanner-profile-path' => "/#{project.full_path}/-/security/configuration/dast_scans/dast_scanner_profiles/new",
'new-site-profile-path' => "/#{project.full_path}/-/security/configuration/dast_scans/dast_site_profiles/new",
'timezones' => timezones.to_json
)
end
end
......
......@@ -4,16 +4,23 @@ require 'spec_helper'
RSpec.describe Projects::Security::DastProfilesHelper do
describe '#dast_profiles_list_data' do
let(:project) { create(:project) }
let_it_be(:project) { create(:project) }
let_it_be(:path_with_namespace) { 'foo/bar' }
let_it_be(:timezones) { [{ identifier: "Europe/Paris" }] }
before do
allow(project).to receive(:path_with_namespace).and_return(path_with_namespace)
allow(helper).to receive(:timezone_data).with(format: :full).and_return(timezones)
end
it 'returns proper data' do
expect(helper.dast_profiles_list_data(project)).to eq(
{
'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,
'timezones' => helper.timezone_data(format: :full).to_json
'new_dast_saved_scan_path' => "/#{project.full_path}/-/on_demand_scans/new",
'new_dast_site_profile_path' => "/#{project.full_path}/-/security/configuration/dast_scans/dast_site_profiles/new",
'new_dast_scanner_profile_path' => "/#{project.full_path}/-/security/configuration/dast_scans/dast_scanner_profiles/new",
'project_full_path' => path_with_namespace,
'timezones' => timezones.to_json
}
)
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