Commit b4b12c9f authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '349058-refactor-project-security-discover-data-attributes' into 'master'

Refactor project security discover data attributes

See merge request gitlab-org/gitlab!78306
parents 3fb4b02e 24b1e48a
......@@ -7,4 +7,23 @@ module Projects::Security::DiscoverHelper
e.try { true }
end.run
end
def project_security_discover_data(project)
content = pql_three_cta_test_experiment_candidate?(project.root_ancestor) ? 'discover-project-security-pqltest' : 'discover-project-security'
link_upgrade = project.personal? ? profile_billings_path(project.group, source: content) : group_billings_path(@project.root_ancestor, source: content)
data = {
project: {
id: project.id,
name: project.name
},
link: {
main: new_trial_registration_path(glm_source: 'gitlab.com', glm_content: content),
secondary: link_upgrade,
feedback: 'https://gitlab.com/gitlab-org/growth/ui-ux/issues/25'
}
}
data.merge(hand_raise_props(project.root_ancestor))
end
end
- breadcrumb_title _("Security Dashboard")
- page_title _("Security Dashboard")
- add_page_specific_style 'page_bundles/security_discover'
- linkFeedback = 'https://gitlab.com/gitlab-org/growth/ui-ux/issues/25'
- content = pql_three_cta_test_experiment_candidate?(@project.root_ancestor) ? 'discover-project-security-pqltest' : 'discover-project-security'
- linkUpgrade = @project.personal? ? profile_billings_path(@project.group, source: content) : group_billings_path(@project.root_ancestor, source: content)
- data = { project: { id: @project.id, name: @project.name }, link: { main: new_trial_registration_path(glm_source: 'gitlab.com', glm_content: content), secondary: linkUpgrade, feedback: linkFeedback } }
- data.merge!(hand_raise_props(@project.root_ancestor))
#js-security-discover-app{ data: data }
#js-security-discover-app{ data: project_security_discover_data(@project) }
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::Security::DiscoverHelper do
describe '#project_security_discover_data' do
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let(:variant) { :control }
let(:content) { 'discover-project-security' }
let(:expected_project_security_discover_data) do
{
project: {
id: project.id,
name: project.name
},
link: {
main: new_trial_registration_path(glm_source: 'gitlab.com', glm_content: content),
secondary: profile_billings_path(project.group, source: content),
feedback: 'https://gitlab.com/gitlab-org/growth/ui-ux/issues/25'
}
}.merge(helper.hand_raise_props(project.root_ancestor))
end
subject(:project_security_discover_data) do
helper.project_security_discover_data(project)
end
before do
allow(helper).to receive(:current_user).and_return(user)
stub_experiments(pql_three_cta_test: variant)
end
it 'builds correct hash' do
expect(project_security_discover_data).to eq(expected_project_security_discover_data)
end
context 'candidate for pql_three_cta_test' do
let(:variant) { :candidate }
let(:content) { 'discover-project-security-pqltest' }
it 'renders a hash with pqltest content' do
expect(project_security_discover_data).to eq(expected_project_security_discover_data)
end
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