Commit 2a218504 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'refactor-dast-rspec' into 'master'

Rewrite assertions with hardcoded values

See merge request gitlab-org/gitlab!70041
parents d031d65f fa483f7a
......@@ -4,20 +4,27 @@ 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(: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("foo/bar")
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_page_path('user/application_security/dast/index', anchor: 'on-demand-scans'),
'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' => "foo/bar",
'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,22 @@ 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(:timezones) { [{ identifier: "Europe/Paris" }] }
before do
allow(project).to receive(:path_with_namespace).and_return("foo/bar")
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 match(
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' => "foo/bar",
'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