Commit 07533e37 authored by Alper Akgun's avatar Alper Akgun Committed by Markus Koller

Add parameters to in app purchase links

Changelog: changed
parent bc070a39
......@@ -133,6 +133,14 @@ module BillingPlansHelper
!namespace.free_personal? && namespace.eligible_for_trial?
end
def plan_purchase_url(group, plan)
if use_new_purchase_flow?(group)
new_subscriptions_path(plan_id: plan.id, namespace_id: group.id, source: params[:source])
else
"#{plan.purchase_link.href}&gl_namespace_id=#{group.id}"
end
end
private
def add_seats_url(group)
......@@ -141,14 +149,6 @@ module BillingPlansHelper
"#{EE::SUBSCRIPTIONS_URL}/gitlab/namespaces/#{group.id}/extra_seats"
end
def plan_purchase_url(group, plan)
if use_new_purchase_flow?(group)
new_subscriptions_path(plan_id: plan.id, namespace_id: group.id)
else
"#{plan.purchase_link.href}&gl_namespace_id=#{group.id}"
end
end
def plan_upgrade_url(group, plan)
return unless group && plan&.id
......
......@@ -2,6 +2,7 @@
- page_title _("Security")
- add_page_specific_style 'page_bundles/security_discover'
- linkFeedback = 'https://gitlab.com/gitlab-org/growth/ui-ux/issues/25'
- linkUpgrade = group_billings_path(@group.root_ancestor)
- content = 'discover-group-security'
- linkUpgrade = group_billings_path(@group.root_ancestor, source: content)
#js-security-discover-app{ data: { group: { id: @group.id, name: @group.name }, link: { main: new_trial_registration_path(glm_source: 'gitlab.com', glm_content: 'discover-group-security'), secondary: linkUpgrade, feedback: linkFeedback } } }
#js-security-discover-app{ data: { group: { id: @group.id, name: @group.name }, link: { main: new_trial_registration_path(glm_source: 'gitlab.com', glm_content: content), secondary: linkUpgrade, feedback: linkFeedback } } }
......@@ -2,6 +2,7 @@
- page_title _("Security Dashboard")
- add_page_specific_style 'page_bundles/security_discover'
- linkFeedback = 'https://gitlab.com/gitlab-org/growth/ui-ux/issues/25'
- linkUpgrade = @project.personal? ? profile_billings_path(@project.group) : group_billings_path(@project.root_ancestor)
- content = 'discover-project-security'
- linkUpgrade = @project.personal? ? profile_billings_path(@project.group, source: content) : group_billings_path(@project.root_ancestor, source: content)
#js-security-discover-app{ data: { project: { id: @project.id, name: @project.name }, link: { main: new_trial_registration_path(glm_source: 'gitlab.com', glm_content: 'discover-project-security'), secondary: linkUpgrade, feedback: linkFeedback } } }
#js-security-discover-app{ 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 } } }
......@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe BillingPlansHelper do
include Devise::Test::ControllerHelpers
describe '#subscription_plan_data_attributes' do
let(:customer_portal_url) { "#{EE::SUBSCRIPTIONS_URL}/subscriptions" }
......@@ -356,11 +358,36 @@ RSpec.describe BillingPlansHelper do
group = double('Group', upgradable?: false)
expect(helper).to receive(:plan_purchase_url)
helper.plan_purchase_or_upgrade_url(group, plan)
end
end
describe "#plan_purchase_url" do
let_it_be(:group) { create(:group) }
let_it_be(:user) { create(:user) }
let(:plan) { double('Plan', id: '123456789', purchase_link: double('PurchaseLink', href: '987654321')) }
before do
allow(helper).to receive(:current_user).and_return(user)
end
it 'builds correct url with some source' do
allow(helper).to receive(:use_new_purchase_flow?).and_return(true)
allow(helper).to receive(:params).and_return({ source: 'some_source' })
expect(helper).to receive(:new_subscriptions_path).with(plan_id: plan.id, namespace_id: group.id, source: 'some_source')
helper.plan_purchase_url(group, plan)
end
it 'builds correct url for the old purchase flow' do
allow(helper).to receive(:use_new_purchase_flow?).and_return(false)
expect(helper.plan_purchase_url(group, plan)).to eq("#{plan.purchase_link.href}&gl_namespace_id=#{group.id}")
end
end
describe '#upgrade_button_css_classes' do
using RSpec::Parameterized::TableSyntax
......
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