Commit 1983c5ff authored by Changzheng Liu's avatar Changzheng Liu Committed by Doug Stull

Advanced Search should index trials regardless of seats

Changelog: fixed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66665
EE: true
parent c24915f8
...@@ -162,7 +162,9 @@ class GitlabSubscription < ApplicationRecord ...@@ -162,7 +162,9 @@ class GitlabSubscription < ApplicationRecord
return false unless ::Gitlab.dev_env_or_com? return false unless ::Gitlab.dev_env_or_com?
return false if expired? return false if expired?
has_a_paid_hosted_plan?(include_trials: true) # We only index paid groups on dot com for now.
# If the namespace is in trial, seats will be ignored.
Plan::PAID_HOSTED_PLANS.include?(plan_name) && (trial? || seats > 0)
end end
# Kick off Elasticsearch indexing for paid groups with new or upgraded paid, hosted subscriptions # Kick off Elasticsearch indexing for paid groups with new or upgraded paid, hosted subscriptions
......
...@@ -352,8 +352,28 @@ RSpec.describe GitlabSubscription do ...@@ -352,8 +352,28 @@ RSpec.describe GitlabSubscription do
gitlab_subscription.save! gitlab_subscription.save!
end end
context 'when seats is 0' do
let(:gitlab_subscription) { build(:gitlab_subscription, namespace: namespace, seats: 0) }
it 'does not index the namespace' do
expect(ElasticsearchIndexedNamespace).not_to receive(:safe_find_or_create_by!)
gitlab_subscription.save!
end
end
context 'when it is a trial' do context 'when it is a trial' do
let(:gitlab_subscription) { build(:gitlab_subscription, :active_trial, namespace: namespace) } let(:seats) { 10 }
let(:gitlab_subscription) { build(:gitlab_subscription, :active_trial, namespace: namespace, seats: seats) }
it 'indexes the namespace' do
expect(ElasticsearchIndexedNamespace).to receive(:safe_find_or_create_by!).with(namespace_id: gitlab_subscription.namespace_id)
gitlab_subscription.save!
end
context 'when seats is zero' do
let(:seats) { 0 }
it 'indexes the namespace' do it 'indexes the namespace' do
expect(ElasticsearchIndexedNamespace).to receive(:safe_find_or_create_by!).with(namespace_id: gitlab_subscription.namespace_id) expect(ElasticsearchIndexedNamespace).to receive(:safe_find_or_create_by!).with(namespace_id: gitlab_subscription.namespace_id)
...@@ -362,6 +382,17 @@ RSpec.describe GitlabSubscription do ...@@ -362,6 +382,17 @@ RSpec.describe GitlabSubscription do
end end
end end
context 'when in free plan' do
let(:gitlab_subscription) { build(:gitlab_subscription, :active_trial, namespace: namespace, seats: seats, hosted_plan_id: nil) }
it 'does not index the namespace' do
expect(ElasticsearchIndexedNamespace).not_to receive(:safe_find_or_create_by!)
gitlab_subscription.save!
end
end
end
context 'when not ::Gitlab.dev_env_or_com?' do context 'when not ::Gitlab.dev_env_or_com?' do
let(:dev_env_or_com) { false } let(:dev_env_or_com) { false }
......
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