Commit 16a78be0 authored by Vijay Hawoldar's avatar Vijay Hawoldar

Exclude guests being billable for ultimate trials

Guests users are not considered billable for ultimate plan customers,
this change applies the same logic to ultimate trial customers

Changelog: changed
EE: true
parent 56c44a68
......@@ -349,7 +349,7 @@ module EE
# For the user_ids key, we are plucking the user_ids from the "Members" table in an array and
# converting the array of user_ids to a Set which will have unique user_ids.
def billed_user_ids(requested_hosted_plan = nil)
exclude_guests = ([actual_plan_name, requested_hosted_plan] & [::Plan::GOLD, ::Plan::ULTIMATE]).any?
exclude_guests = ([actual_plan_name, requested_hosted_plan] & [::Plan::GOLD, ::Plan::ULTIMATE, ::Plan::ULTIMATE_TRIAL]).any?
exclude_guests ? billed_user_ids_excluding_guests : billed_user_ids_including_guests
end
......
......@@ -978,11 +978,7 @@ RSpec.describe Namespace do
])
end
context 'with a ultimate plan' do
before do
create(:gitlab_subscription, namespace: group, hosted_plan: ultimate_plan)
end
shared_examples 'ultimate plan' do
it 'does not include guest users and only active users' do
expect(billed_user_ids[:user_ids]).to match_array([developer.id])
end
......@@ -1118,6 +1114,22 @@ RSpec.describe Namespace do
end
end
context 'with a ultimate plan' do
before do
create(:gitlab_subscription, :ultimate, namespace: group)
end
it_behaves_like 'ultimate plan'
end
context 'with an ultimate trial plan' do
before do
create(:gitlab_subscription, :ultimate_trial, namespace: group)
end
it_behaves_like 'ultimate plan'
end
context 'with other plans' do
%i[bronze_plan premium_plan].each do |plan|
subject(:billed_user_ids) { group.billed_user_ids }
......
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