Commit 1d632a1e authored by Doug Stull's avatar Doug Stull

Merge branch '335975-index-trials-regardless-seat' into 'master'

Advanced Search should index trials regardless of seats

See merge request gitlab-org/gitlab!66665
parents 0902a6f8 1983c5ff
......@@ -162,7 +162,9 @@ class GitlabSubscription < ApplicationRecord
return false unless ::Gitlab.dev_env_or_com?
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
# Kick off Elasticsearch indexing for paid groups with new or upgraded paid, hosted subscriptions
......
......@@ -352,8 +352,28 @@ RSpec.describe GitlabSubscription do
gitlab_subscription.save!
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
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
expect(ElasticsearchIndexedNamespace).to receive(:safe_find_or_create_by!).with(namespace_id: gitlab_subscription.namespace_id)
......@@ -362,6 +382,17 @@ RSpec.describe GitlabSubscription do
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
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