Commit 0c406c18 authored by dzubova's avatar dzubova

Show banner after storage purchase

Redirect to usage-quotas#storage-quota-tab after purchase
Refactor buy_addon_data method to be more generic

EE: true
parent c1089d13
......@@ -16,15 +16,9 @@ module SubscriptionsHelper
}
end
def buy_minutes_addon_data(group)
def buy_addon_data(group, anchor, purchased_product)
{
redirect_after_success: group_usage_quotas_path(group, anchor: 'pipelines-quota-tab', purchased_product: _('CI minutes'))
}.merge(addon_data(group))
end
def buy_storage_addon_data(group)
{
redirect_after_success: group_usage_quotas_path(group, anchor: 'storage-quota-tab', purchased_product: _('Storage'))
redirect_after_success: group_usage_quotas_path(group, anchor: anchor, purchased_product: purchased_product)
}.merge(addon_data(group))
end
......
- page_title _('Buy CI Minutes')
#js-buy-minutes{ data: buy_minutes_addon_data(@group) }
#js-buy-minutes{ data: buy_addon_data(@group, 'pipelines-quota-tab', _('CI minutes')) }
- page_title _('Buy Storage')
#js-buy-storage{ data: buy_storage_addon_data(@group) }
#js-buy-storage{ data: buy_addon_data(@group, 'storage-quota-tab', s_('Checkout|a storage subscription')) }
......@@ -150,29 +150,14 @@ RSpec.describe SubscriptionsHelper do
it { is_expected.to include(group_data: %Q{[{"id":#{group.id},"name":"My Namespace","users":1,"guests":0}]}) }
end
describe '#buy_minutes_addon_data' do
subject(:buy_minutes_addon_data) { helper.buy_minutes_addon_data(group) }
describe '#buy_addon_data' do
subject(:buy_addon_data) { helper.buy_addon_data(group, anchor, purchased_product) }
let_it_be(:user) { create(:user, name: 'First Last') }
let_it_be(:group) { create(:group, name: 'My Namespace') }
before do
allow(helper).to receive(:current_user).and_return(user)
allow(helper).to receive(:params).and_return({ selected_group: group.id.to_s, source: 'some_source' })
group.add_owner(user)
end
it { is_expected.to include(namespace_id: group.id.to_s) }
it { is_expected.to include(source: 'some_source') }
it { is_expected.to include(group_data: %Q{[{"id":#{group.id},"name":"My Namespace","users":1,"guests":0}]}) }
it { is_expected.to include(redirect_after_success: group_usage_quotas_path(group, anchor: 'pipelines-quota-tab', purchased_product: 'CI minutes')) }
end
describe '#buy_storage_addon_data' do
subject(:buy_storage_addon_data) { helper.buy_storage_addon_data(group) }
let_it_be(:user) { create(:user, name: 'First Last') }
let_it_be(:group) { create(:group, name: 'My Namespace') }
let(:anchor) { 'pipelines-quota-tab' }
let(:purchased_product) { 'CI Minutes' }
before do
allow(helper).to receive(:current_user).and_return(user)
......@@ -183,6 +168,6 @@ RSpec.describe SubscriptionsHelper do
it { is_expected.to include(namespace_id: group.id.to_s) }
it { is_expected.to include(source: 'some_source') }
it { is_expected.to include(group_data: %Q{[{"id":#{group.id},"name":"My Namespace","users":1,"guests":0}]}) }
it { is_expected.to include(redirect_after_success: group_usage_quotas_path(group, anchor: 'storage-quota-tab', purchased_product: 'Storage')) }
it { is_expected.to include(redirect_after_success: group_usage_quotas_path(group, anchor: anchor, purchased_product: purchased_product)) }
end
end
......@@ -22,12 +22,12 @@ end
RSpec.shared_examples_for 'buy minutes addon form data' do |js_selector|
before do
allow(view).to receive(:buy_minutes_addon_data).and_return(
allow(view).to receive(:buy_addon_data).and_return(
group_data: '[{"id":"ci_minutes_plan_id","code":"ci_minutes","price_per_year":10.0}]',
namespace_id: '1',
plan_id: 'ci_minutes_plan_id',
source: 'some_source',
redirect_after_success: '/groups/my-ci-minutes-group/-/usage_quotas'
redirect_after_success: '/groups/my-ci-minutes-group/-/usage_quotas#pipelines-quota-tab'
)
end
......@@ -37,17 +37,17 @@ RSpec.shared_examples_for 'buy minutes addon form data' do |js_selector|
it { is_expected.to have_selector("#{js_selector}[data-plan-id='ci_minutes_plan_id']") }
it { is_expected.to have_selector("#{js_selector}[data-namespace-id='1']") }
it { is_expected.to have_selector("#{js_selector}[data-source='some_source']") }
it { is_expected.to have_selector("#{js_selector}[data-redirect-after-success='/groups/my-ci-minutes-group/-/usage_quotas']") }
it { is_expected.to have_selector("#{js_selector}[data-redirect-after-success='/groups/my-ci-minutes-group/-/usage_quotas#pipelines-quota-tab']") }
end
RSpec.shared_examples_for 'buy storage addon form data' do |js_selector|
before do
allow(view).to receive(:buy_storage_addon_data).and_return(
allow(view).to receive(:buy_addon_data).and_return(
group_data: '[{"id":"storage_plan_id","code":"storage","price_per_year":10.0}]',
namespace_id: '2',
plan_id: 'storage_plan_id',
source: 'some_source',
redirect_after_success: '/groups/my-group/-/usage_quotas'
redirect_after_success: '/groups/my-group/-/usage_quotas#storage-quota-tab'
)
end
......@@ -57,5 +57,5 @@ RSpec.shared_examples_for 'buy storage addon form data' do |js_selector|
it { is_expected.to have_selector("#{js_selector}[data-plan-id='storage_plan_id']") }
it { is_expected.to have_selector("#{js_selector}[data-namespace-id='2']") }
it { is_expected.to have_selector("#{js_selector}[data-source='some_source']") }
it { is_expected.to have_selector("#{js_selector}[data-redirect-after-success='/groups/my-group/-/usage_quotas']") }
it { is_expected.to have_selector("#{js_selector}[data-redirect-after-success='/groups/my-group/-/usage_quotas#storage-quota-tab']") }
end
......@@ -6760,6 +6760,9 @@ msgstr ""
msgid "Checkout|Zip code"
msgstr ""
msgid "Checkout|a storage subscription"
msgstr ""
msgid "Checkout|company or team"
msgstr ""
......
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