Commit 47ccbc7c authored by Dallas Reedy's avatar Dallas Reedy Committed by Nick Thomas

Omit sub-groups from trial eligibility

parent 1858d57b
......@@ -40,6 +40,7 @@ module EE
scope :eligible_for_trial, -> do
left_joins(gitlab_subscription: :hosted_plan)
.where(
parent_id: nil,
gitlab_subscriptions: { trial: [nil, false], trial_ends_on: [nil] },
plans: { name: [nil, *::Plan::PLANS_ELIGIBLE_FOR_TRIAL] }
)
......
---
title: Omit sub-groups from trial selection menu
merge_request: 40300
author:
type: fixed
......@@ -64,7 +64,7 @@ RSpec.describe EE::TrialHelper do
let_it_be(:subgroup2) { create :group, parent: group2, name: 'Sub-Group 2' }
let_it_be(:subsubgroup1) { create :group, parent: subgroup2, name: 'Sub-Sub-Group 1' }
let(:all_groups) { [group1, group2, subgroup1, subgroup2, subsubgroup1].map(&:id) }
let(:top_level_groups) { [group1, group2].map(&:id) }
before do
group1.add_owner(user)
......@@ -72,7 +72,7 @@ RSpec.describe EE::TrialHelper do
end
context 'and none of the groups have subscriptions' do
it { is_expected.to eq(all_groups) }
it { is_expected.to eq(top_level_groups) }
end
context 'and the groups have subscriptions' do
......@@ -89,7 +89,7 @@ RSpec.describe EE::TrialHelper do
let!(:subscription_subsubgroup1) { create :gitlab_subscription, :free, *subsubgroup1_traits, namespace: subsubgroup1 }
context 'and none of the groups have been trialed yet' do
it { is_expected.to eq(all_groups) }
it { is_expected.to eq(top_level_groups) }
end
context 'and some of the groups are being or have been trialed' do
......@@ -97,9 +97,7 @@ RSpec.describe EE::TrialHelper do
let(:subgroup1_traits) { :expired_trial }
let(:subgroup2_traits) { :active_trial }
let(:some_groups) { [group2, subsubgroup1].map(&:id) }
it { is_expected.to eq(some_groups) }
it { is_expected.to eq([group2.id]) }
end
context 'and all of the groups are being or have been trialed' do
......
......@@ -1058,6 +1058,7 @@ RSpec.describe User do
let_it_be(:non_trialed_group_z) { create :group, name: 'Zeta', gitlab_subscription: create(:gitlab_subscription, :free) }
let_it_be(:non_trialed_group_a) { create :group, name: 'Alpha', gitlab_subscription: create(:gitlab_subscription, :free) }
let_it_be(:trialed_group) { create :group, name: 'Omitted', gitlab_subscription: create(:gitlab_subscription, :free, trial: true) }
let_it_be(:non_trialed_subgroup) { create :group, name: 'Sub-group', gitlab_subscription: create(:gitlab_subscription, :free), parent: non_trialed_group_a }
subject { user.manageable_groups_eligible_for_trial }
......@@ -1105,6 +1106,14 @@ RSpec.describe User do
it { is_expected.to eq [non_trialed_group_a, non_trialed_group_z] }
end
context 'owner of a top-level group with a sub-group' do
before do
non_trialed_group_a.add_owner(user)
end
it { is_expected.to eq [non_trialed_group_a] }
end
end
describe '#active_for_authentication?' do
......
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