Commit a91a7f94 authored by Etienne Baqué's avatar Etienne Baqué

Merge branch 'vij-billable-guests-ultimate-trial' into 'master'

Exclude guests being billable for ultimate trials

See merge request gitlab-org/gitlab!80284
parents 4ec74ef2 16a78be0
......@@ -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
......
......@@ -977,11 +977,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
......@@ -1117,6 +1113,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