Commit 5e150108 authored by Rubén Dávila's avatar Rubén Dávila

Show button to purchase extra CI minutes only for paid plans

The ability to purchase extra CI minutes is only available for
Namespaces with a paid plan for now. In order to avoid confusion
we should hide this button when the Namespace is using a Free plan.
parent 4d3787ca
......@@ -284,6 +284,10 @@ module EE
actual_plan_name == GOLD_PLAN
end
def paid_plan?
!(free_plan? || early_adopter_plan?)
end
def use_elasticsearch?
::Gitlab::CurrentSettings.elasticsearch_indexes_namespace?(self)
end
......
......@@ -10,6 +10,7 @@
%strong= @group.name
group
- if @group.paid_plan?
.col-sm-6
%p.text-right
= link_to 'Buy additional minutes', 'https://customers.gitlab.com/subscriptions', target: '_blank', class: 'btn btn-inverted btn-success right text-right'
......
......@@ -56,4 +56,36 @@ describe Namespace do
expect(namespace.use_elasticsearch?).to eq(true)
end
end
describe '#paid_plan?' do
using RSpec::Parameterized::TableSyntax
let(:namespace) { create(:namespace) }
before(:all) do
%i[free_plan early_adopter_plan bronze_plan silver_plan gold_plan].each do |plan|
create(plan)
end
end
subject { namespace.paid_plan? }
where(:plan_code, :expected_result) do
described_class::FREE_PLAN | false
described_class::EARLY_ADOPTER_PLAN | false
described_class::BRONZE_PLAN | true
described_class::SILVER_PLAN | true
described_class::GOLD_PLAN | true
end
with_them do
before do
namespace.update!(gitlab_subscription_attributes: { hosted_plan: Plan.find_by_name(plan_code) })
end
it do
is_expected.to eq(expected_result)
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