Skip to content
Snippets Groups Projects
Commit 244b6513 authored by Dmitry Gruzd's avatar Dmitry Gruzd :two:
Browse files

Fix with_hosted_plan when used with trial: nil

Changelog: fixed
EE: true
parent 51363b9c
No related branches found
No related tags found
1 merge request!144185Fix with_hosted_plan when used with trial: nil
......@@ -33,7 +33,7 @@ class GitlabSubscription < ApplicationRecord
end
scope :with_hosted_plan, -> (plan_name) do
joins(:hosted_plan).where(trial: false, 'plans.name' => plan_name)
joins(:hosted_plan).where(trial: [false, nil], 'plans.name' => plan_name)
.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/422013')
end
......
......@@ -36,11 +36,13 @@
describe '.with_hosted_plan' do
let_it_be(:ultimate_subscription) { create(:gitlab_subscription, hosted_plan: ultimate_plan) }
let_it_be(:premium_subscription) { create(:gitlab_subscription, hosted_plan: premium_plan) }
let_it_be(:gold_subscription) { create(:gitlab_subscription, hosted_plan: gold_plan, trial: nil) }
let_it_be(:trial_subscription) { create(:gitlab_subscription, hosted_plan: ultimate_plan, trial: true) }
it 'scopes to the plan' do
expect(described_class.with_hosted_plan('ultimate')).to contain_exactly(ultimate_subscription)
expect(described_class.with_hosted_plan('premium')).to contain_exactly(premium_subscription)
expect(described_class.with_hosted_plan('gold')).to contain_exactly(gold_subscription)
expect(described_class.with_hosted_plan('bronze')).to be_empty
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment