Commit 233ab6aa authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'sh-fix-external-validation-trial-status' into 'master'

Return correct trial status in CI external pipeline validation

See merge request gitlab-org/gitlab!61104
parents a446803d e1a5aaeb
......@@ -287,6 +287,8 @@ module EE
plan_eligible_for_trial?
end
# Be sure to call this on root_ancestor since plans are only associated
# with the top-level namespace, not with subgroups.
def trial_active?
trial? && trial_ends_on.present? && trial_ends_on >= Date.today
end
......
---
title: Return correct trial status in CI external pipeline validation
merge_request: 61104
author:
type: fixed
......@@ -18,7 +18,7 @@ module EE
super.deep_merge(
namespace: {
plan: namespace.actual_plan_name,
trial: namespace.trial_active?
trial: namespace.root_ancestor.trial_active?
}
)
end
......
......@@ -40,9 +40,13 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do
stub_env('EXTERNAL_VALIDATION_SERVICE_URL', validation_service_url)
end
it 'respects the defined schema' do
it 'respects the defined schema and returns the default plan' do
expect(::Gitlab::HTTP).to receive(:post) do |_url, params|
expect(params[:body]).to match_schema('/external_validation', dir: 'ee')
payload = Gitlab::Json(params[:body])
expect(payload.dig('namespace', 'plan')).to eq('default')
expect(payload.dig('namespace', 'trial')).to be false
end
step.perform!
......@@ -53,5 +57,21 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do
expect { step.perform! }.not_to exceed_query_limit(4)
end
context 'with a project in a subgroup' do
let(:group) { create(:group_with_plan, plan: :ultimate_plan, trial_ends_on: Date.tomorrow) }
let(:subgroup) { create(:group, parent: group) }
let(:project) { create(:project, namespace: subgroup, shared_runners_enabled: true) }
it 'returns an Ultimate plan on trial' do
expect(::Gitlab::HTTP).to receive(:post) do |_url, params|
payload = Gitlab::Json.parse(params[:body])
expect(payload.dig('namespace', 'plan')).to eq('ultimate')
expect(payload.dig('namespace', 'trial')).to be true
end
step.perform!
end
end
end
end
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