Commit 58545de8 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Make `ci_cd_projects` globally available for .com

The coming year `ci_cd_projects` should be available for _all_
projects on GitLab.com. So making them global features allows all
projects to use them.

For that to work, we also need to enable `repository_mirrors` and
`github_project_service_integration` so the projects can correctly be
mirrored to allow CI to run.
parent 27db2abb
...@@ -87,6 +87,8 @@ module EE ...@@ -87,6 +87,8 @@ module EE
end end
def feature_available_in_plan?(feature) def feature_available_in_plan?(feature)
return true if ::License::ANY_PLAN_FEATURES.include?(feature)
available_features = strong_memoize(:features_available_in_plan) do available_features = strong_memoize(:features_available_in_plan) do
Hash.new do |h, feature| Hash.new do |h, feature|
h[feature] = (plans.map(&:name) & self.class.plans_with_feature(feature)).any? h[feature] = (plans.map(&:name) & self.class.plans_with_feature(feature)).any?
......
...@@ -124,6 +124,13 @@ class License < ActiveRecord::Base ...@@ -124,6 +124,13 @@ class License < ActiveRecord::Base
'GitLab_ServiceDesk' => :service_desk 'GitLab_ServiceDesk' => :service_desk
}.freeze }.freeze
# Features added here are available for all namespaces.
ANY_PLAN_FEATURES = %i[
ci_cd_projects
repository_mirrors
github_project_service_integration
].freeze
# Global features that cannot be restricted to only a subset of projects or namespaces. # Global features that cannot be restricted to only a subset of projects or namespaces.
# Use `License.feature_available?(:feature)` to check if these features are available. # Use `License.feature_available?(:feature)` to check if these features are available.
# For all other features, use `project.feature_available?` or `namespace.feature_available?` when possible. # For all other features, use `project.feature_available?` or `namespace.feature_available?` when possible.
......
...@@ -195,12 +195,13 @@ describe Namespace do ...@@ -195,12 +195,13 @@ describe Namespace do
describe '#feature_available?' do describe '#feature_available?' do
let(:plan_license) { :bronze_plan } let(:plan_license) { :bronze_plan }
let(:group) { create(:group, plan: plan_license) } let(:group) { create(:group, plan: plan_license) }
let(:feature) { :service_desk } let(:licensed_feature) { :service_desk }
let(:feature) { licensed_feature }
subject { group.feature_available?(feature) } subject { group.feature_available?(feature) }
before do before do
stub_licensed_features(feature => true) stub_licensed_features(licensed_feature => true)
end end
it 'uses the global setting when running on premise' do it 'uses the global setting when running on premise' do
...@@ -253,6 +254,25 @@ describe Namespace do ...@@ -253,6 +254,25 @@ describe Namespace do
end end
end end
end end
context 'when the feature is temporarily available on the entire instance' do
let(:license_plan) { :free_plan }
let(:feature) { :ci_cd_projects }
before do
stub_application_setting_on_object(group, should_check_namespace_plan: true)
end
it 'returns true when the feature is available globally' do
stub_licensed_features(feature => true)
is_expected.to be_truthy
end
it 'returns `false` when the feature is not included in the global license' do
is_expected.to be_falsy
end
end
end end
describe '#max_active_pipelines' do describe '#max_active_pipelines' do
......
...@@ -1096,6 +1096,8 @@ describe Project do ...@@ -1096,6 +1096,8 @@ describe Project do
shared_examples 'project with disabled services' do shared_examples 'project with disabled services' do
it 'has some disabled services' do it 'has some disabled services' do
stub_const('License::ANY_PLAN_FEATURES', [])
expect(project.disabled_services).to match_array(disabled_services) expect(project.disabled_services).to match_array(disabled_services)
end end
end end
......
...@@ -115,6 +115,7 @@ describe Projects::CreateService, '#execute' do ...@@ -115,6 +115,7 @@ describe Projects::CreateService, '#execute' do
context 'with checks on the namespace' do context 'with checks on the namespace' do
before do before do
stub_const('License::ANY_PLAN_FEATURES', [])
enable_namespace_license_check! enable_namespace_license_check!
end end
......
...@@ -74,6 +74,7 @@ describe UpdateAllMirrorsWorker do ...@@ -74,6 +74,7 @@ describe UpdateAllMirrorsWorker do
stub_licensed_features(repository_mirrors: true) stub_licensed_features(repository_mirrors: true)
stub_application_setting(check_namespace_plan: true) stub_application_setting(check_namespace_plan: true)
allow(Gitlab).to receive_messages(com?: true) allow(Gitlab).to receive_messages(com?: true)
stub_const('License::ANY_PLAN_FEATURES', [])
end end
let!(:unlicensed_project1) { scheduled_mirror(at: 8.weeks.ago, licensed: false) } let!(:unlicensed_project1) { scheduled_mirror(at: 8.weeks.ago, licensed: 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