Commit a6c1e34b authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch...

Merge branch '247124-purchase-confirmation-banner-does-not-appear-when-users-upgrade-their-group-from-free-to-paid' into 'master'

Show purchase confirmation banner for purchases for existing groups

See merge request gitlab-org/gitlab!45786
parents afb61632 019a554f
...@@ -174,6 +174,10 @@ module GroupsHelper ...@@ -174,6 +174,10 @@ module GroupsHelper
!multiple_members?(group) !multiple_members?(group)
end end
def show_thanks_for_purchase_banner?
params.key?(:purchased_quantity) && params[:purchased_quantity].to_i > 0
end
private private
def just_created? def just_created?
......
- breadcrumb_title _("Details") - breadcrumb_title _("Details")
- @content_class = "limit-container-width" unless fluid_layout - @content_class = "limit-container-width" unless fluid_layout
- if show_thanks_for_purchase_banner?
= render_if_exists 'shared/thanks_for_purchase_banner', plan_title: plan_title, quantity: params[:purchased_quantity].to_i
- if show_invite_banner?(@group) - if show_invite_banner?(@group)
= content_for :group_invite_members_banner do = content_for :group_invite_members_banner do
.container-fluid.container-limited{ class: "gl-pb-2! gl-pt-6! #{@content_class}" } .container-fluid.container-limited{ class: "gl-pb-2! gl-pt-6! #{@content_class}" }
......
...@@ -60,10 +60,10 @@ class SubscriptionsController < ApplicationController ...@@ -60,10 +60,10 @@ class SubscriptionsController < ApplicationController
).execute ).execute
if response[:success] if response[:success]
plan_id, quantity = subscription_params.values_at(:plan_id, :quantity)
redirect_location = if params[:selected_group] redirect_location = if params[:selected_group]
group_path(group) group_path(group, plan_id: plan_id, purchased_quantity: quantity)
else else
plan_id, quantity = subscription_params.values_at(:plan_id, :quantity)
edit_subscriptions_group_path(group.path, plan_id: plan_id, quantity: quantity, new_user: params[:new_user]) edit_subscriptions_group_path(group.path, plan_id: plan_id, quantity: quantity, new_user: params[:new_user])
end end
......
%section.gl-banner.gl-banner-introduction.gl-p-3.px-lg-6
.gl-banner-illustration.gl-display-flex
= image_tag('illustrations/illustration-congratulation-purchase.svg', class: 'mw-xs')
.gl-banner-content.gl-display-flex.gl-flex-direction-column.gl-justify-content-center
%h3= _('Thanks for your purchase!')
- number_of_users = n_('1 user', '%{num} users', quantity) % { num: quantity }
%p= _('You have successfully purchased a %{plan} plan subscription for %{seats}. You’ll receive a receipt via email.') % { plan: plan_title, seats: number_of_users }
...@@ -2,13 +2,7 @@ ...@@ -2,13 +2,7 @@
.row.flex-grow-1.bg-gray-light .row.flex-grow-1.bg-gray-light
.d-flex.flex-column.align-items-center.w-100.gl-p-5 .d-flex.flex-column.align-items-center.w-100.gl-p-5
%section.gl-banner.gl-banner-introduction.gl-p-3.px-lg-6 = render 'shared/thanks_for_purchase_banner', plan_title: plan_title, quantity: params[:quantity].to_i
.gl-banner-illustration.d-flex
= image_tag('illustrations/subscription-success.svg', class: 'mw-xs')
.gl-banner-content.d-flex.flex-column.justify-content-center
%h3= _('Thanks for your purchase!')
- number_of_users = n_('1 user', '%{num} users', params[:quantity].to_i) % { num: params[:quantity] }
%p= _('You have successfully purchased a %{plan} plan subscription for %{seats}. You’ll receive a receipt via email.') % { plan: plan_title, seats: number_of_users }
.edit-group.d-flex.flex-column.align-items-center.gl-pt-7 .edit-group.d-flex.flex-column.align-items-center.gl-pt-7
- if params[:new_user] - if params[:new_user]
#progress-bar #progress-bar
......
---
title: Show purchase confirmation banner when user makes new purchases for existing
groups
merge_request: 45786
author:
type: fixed
...@@ -211,7 +211,10 @@ RSpec.describe SubscriptionsController do ...@@ -211,7 +211,10 @@ RSpec.describe SubscriptionsController do
it 'returns the selected group location in JSON format' do it 'returns the selected group location in JSON format' do
subject subject
expect(response.body).to eq({ location: "/#{selected_group.path}" }.to_json) plan_id = params[:subscription][:plan_id]
quantity = params[:subscription][:quantity]
expect(response.body).to eq({ location: "/#{selected_group.path}?plan_id=#{plan_id}&purchased_quantity=#{quantity}" }.to_json)
end end
context 'when selected group is a sub group' do context 'when selected group is a sub group' do
......
...@@ -370,6 +370,26 @@ RSpec.describe GroupsHelper do ...@@ -370,6 +370,26 @@ RSpec.describe GroupsHelper do
end end
end end
describe '#show_thanks_for_purchase_banner?' do
subject { helper.show_thanks_for_purchase_banner? }
it 'returns true with purchased_quantity present in params' do
allow(controller).to receive(:params) { { purchased_quantity: '1' } }
is_expected.to be_truthy
end
it 'returns false with purchased_quantity not present in params' do
is_expected.to be_falsey
end
it 'returns false with purchased_quantity is empty in params' do
allow(controller).to receive(:params) { { purchased_quantity: '' } }
is_expected.to be_falsey
end
end
describe '#show_invite_banner?' do describe '#show_invite_banner?' do
let_it_be(:current_user) { create(:user) } let_it_be(:current_user) { create(:user) }
let_it_be_with_refind(:group) { create(:group) } let_it_be_with_refind(:group) { create(:group) }
......
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