Commit 27165fc1 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'recreate-ff-for-merge-trains' into 'master'

Recreate feature flags for merge trains

See merge request gitlab-org/gitlab!24844
parents 3c8faad1 f56b96b8
......@@ -8,9 +8,15 @@ module EE
project.feature_available?(:merge_pipelines) && super
end
##
# The `disable_merge_trains` feature flag is meant to be used for dogfooding
# pipelines for merged results in gitlab-org/gitlab project.
# This feature flag is never meant to be enabled for the entire instance.
# See more context in https://gitlab.com/gitlab-org/gitlab/issues/200037
def merge_trains_enabled?
merge_pipelines_enabled? && project.feature_available?(:merge_trains) &&
::Feature.enabled?(:merge_trains_enabled, project, default_enabled: true)
return false if ::Feature.enabled?(:disable_merge_trains, project)
merge_pipelines_enabled? && project.feature_available?(:merge_trains)
end
def merge_pipelines_were_disabled?
......
......@@ -24,6 +24,7 @@ describe 'Merge requests > User merges immediately', :js do
end
before do
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_pipelines: true, merge_trains: true)
stub_ci_pipeline_yaml_file(YAML.dump(ci_yaml))
......
......@@ -28,6 +28,7 @@ describe 'Two merge requests on a merge train' do
end
before do
stub_feature_flags(disable_merge_trains: false)
project.add_maintainer(maintainer_1)
project.add_maintainer(maintainer_2)
stub_licensed_features(merge_pipelines: true, merge_trains: true)
......
......@@ -17,6 +17,7 @@ describe 'User adds a merge request to a merge train', :js do
end
before do
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_pipelines: true, merge_trains: true)
project.add_maintainer(user)
project.update!(merge_pipelines_enabled: true)
......
......@@ -15,6 +15,7 @@ describe 'User adds to merge train when pipeline succeeds', :js do
let(:pipeline) { merge_request.all_pipelines.first }
before do
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_pipelines: true, merge_trains: true)
project.add_maintainer(user)
project.update!(merge_pipelines_enabled: true)
......
......@@ -3,6 +3,10 @@
require 'spec_helper'
describe ProjectCiCdSetting do
before do
stub_feature_flags(disable_merge_trains: false)
end
describe '#merge_pipelines_enabled?' do
subject { project.merge_pipelines_enabled? }
......
......@@ -11,6 +11,7 @@ describe MergeRequestPollWidgetEntity do
let(:request) { double('request', current_user: user) }
before do
stub_feature_flags(disable_merge_trains: false)
project.add_developer(user)
end
......@@ -33,7 +34,7 @@ describe MergeRequestPollWidgetEntity do
context 'when the merge train feature is disabled' do
before do
stub_feature_flags(merge_trains_enabled: false)
stub_feature_flags(disable_merge_trains: true)
end
it 'does not have merge trains count' do
......
......@@ -16,6 +16,7 @@ describe AutoMerge::AddToMergeTrainWhenPipelineSucceedsService do
let(:pipeline) { merge_request.reload.all_pipelines.first }
before do
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_trains: true, merge_pipelines: true)
project.add_maintainer(user)
project.update!(merge_pipelines_enabled: true)
......
......@@ -20,6 +20,7 @@ describe AutoMerge::MergeTrainService do
allow(AutoMergeProcessWorker).to receive(:perform_async) { }
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_trains: true, merge_pipelines: true)
project.update!(merge_pipelines_enabled: true)
end
......@@ -263,7 +264,7 @@ describe AutoMerge::MergeTrainService do
context 'when merge trains project option is disabled' do
before do
stub_feature_flags(merge_trains_enabled: false)
stub_feature_flags(disable_merge_trains: true)
end
it { is_expected.to be_falsy }
......
......@@ -9,6 +9,7 @@ describe MergeTrains::CheckStatusService do
let(:previous_ref) { 'refs/heads/master' }
before do
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_pipelines: true, merge_trains: true)
project.update!(merge_pipelines_enabled: true)
end
......
......@@ -9,6 +9,7 @@ describe MergeTrains::CreatePipelineService do
let(:previous_ref) { 'refs/heads/master' }
before do
stub_feature_flags(disable_merge_trains: false)
project.add_maintainer(maintainer)
stub_licensed_features(merge_pipelines: true, merge_trains: true)
project.update!(merge_pipelines_enabled: true)
......@@ -35,7 +36,7 @@ describe MergeTrains::CreatePipelineService do
context 'when merge trains option is disabled' do
before do
stub_feature_flags(merge_trains_enabled: false)
stub_feature_flags(disable_merge_trains: true)
end
it_behaves_like 'returns an error' do
......
......@@ -9,6 +9,7 @@ describe MergeTrains::RefreshMergeRequestService do
let(:require_recreate) { false }
before do
stub_feature_flags(disable_merge_trains: false)
project.add_maintainer(maintainer)
stub_licensed_features(merge_pipelines: true, merge_trains: true)
project.update!(merge_pipelines_enabled: true)
......
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