Commit 7c5774a4 authored by Vitaly Slobodin's avatar Vitaly Slobodin Committed by Mikołaj Wawrzyniak

Hide billing plans with hide card attribute

parent aee6da52
......@@ -34,13 +34,13 @@ module SubscriptionsHelper
GitlabSubscriptions::FetchSubscriptionPlansService.new(plan: :free).execute
.map(&:symbolize_keys)
.reject { |plan_data| plan_data[:free] }
.map { |plan_data| plan_data.slice(:id, :code, :price_per_year, :deprecated, :name) }
.map { |plan_data| plan_data.slice(:id, :code, :price_per_year, :deprecated, :name, :hide_card) }
end
def subscription_available_plans
return plans_data unless ::Feature.enabled?(:hide_deprecated_billing_plans)
plans_data.reject { |plan_data| plan_data[:deprecated] }
plans_data.reject { |plan_data| plan_data[:deprecated] || plan_data[:hide_card] }
end
def present_groups(groups)
......
---
title: Hide billing plans with truthy hide_card attribute
merge_request: 61990
author:
type: fixed
......@@ -83,26 +83,29 @@ RSpec.describe SubscriptionsHelper do
it { is_expected.to include(available_plans: '[{"id":"bronze_id","code":"bronze","price_per_year":48.0,"deprecated":true,"name":"Bronze Plan"}]') }
end
context 'when ff purchase_deprecated_plans is enabled' do
before do
stub_feature_flags(hide_deprecated_billing_plans: true)
end
it { is_expected.to include(available_plans: '[{"id":"bronze_id","code":"bronze","price_per_year":48.0,"name":"Bronze Plan"}]') }
context 'when bronze_plan is deprecated' do
context 'when bronze_plan has hide_card attribute set to true' do
let(:bronze_plan) do
{
"id" => "bronze_id",
"name" => "Bronze Plan",
"deprecated" => true,
"deprecated" => false,
"hide_card" => true,
"free" => false,
"code" => "bronze",
"price_per_year" => 48.0
}
end
it { is_expected.to include(available_plans: '[]') }
context 'and is set to hide_deprecated_billing_plans true' do
before do
stub_feature_flags(hide_deprecated_billing_plans: true)
end
it { is_expected.not_to include(available_plans: "[{\"id\":\"bronze_id\",\"code\":\"bronze\",\"price_per_year\":48.0,\"deprecated\":false,\"name\":\"Bronze Plan\",\"hide_card\":true}]") }
end
context 'and is set to false' do
it { is_expected.to include(available_plans: "[{\"id\":\"bronze_id\",\"code\":\"bronze\",\"price_per_year\":48.0,\"deprecated\":false,\"name\":\"Bronze Plan\",\"hide_card\":true}]") }
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