Commit 3ee48e42 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Enable all feature flags by default in specs

Otherwise some features would go untested in non-specific contexts

I did need to disable the
`gitlab_git_diff_size_limit_increase`-feature in some specs since we
depend on diffs being expandable while the file we are testing on is
smaller than the increased limit.
parent 3c197e74
...@@ -4,6 +4,11 @@ feature 'Merge request conflict resolution', js: true, feature: true do ...@@ -4,6 +4,11 @@ feature 'Merge request conflict resolution', js: true, feature: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
before do
# In order to have the diffs collapsed, we need to disable the increase feature
stub_feature_flags(gitlab_git_diff_size_limit_increase: false)
end
def create_merge_request(source_branch) def create_merge_request(source_branch)
create(:merge_request, source_branch: source_branch, target_branch: 'conflict-start', source_project: project) do |mr| create(:merge_request, source_branch: source_branch, target_branch: 'conflict-start', source_project: project) do |mr|
mr.mark_as_unmergeable mr.mark_as_unmergeable
......
...@@ -110,6 +110,10 @@ feature 'Diff file viewer', :js, feature: true do ...@@ -110,6 +110,10 @@ feature 'Diff file viewer', :js, feature: true do
context 'binary file that appears to be text in the first 1024 bytes' do context 'binary file that appears to be text in the first 1024 bytes' do
before do before do
# The file we're visiting is smaller than 10 KB and we want it collapsed
# so we need to disable the size increase feature.
stub_feature_flags(gitlab_git_diff_size_limit_increase: false)
visit_commit('7b1cf4336b528e0f3d1d140ee50cafdbc703597c') visit_commit('7b1cf4336b528e0f3d1d140ee50cafdbc703597c')
end end
......
...@@ -34,7 +34,7 @@ EOT ...@@ -34,7 +34,7 @@ EOT
describe 'size limit feature toggles' do describe 'size limit feature toggles' do
context 'when the feature gitlab_git_diff_size_limit_increase is enabled' do context 'when the feature gitlab_git_diff_size_limit_increase is enabled' do
before do before do
Feature.enable('gitlab_git_diff_size_limit_increase') stub_feature_flags(gitlab_git_diff_size_limit_increase: true)
end end
it 'returns 200 KB for size_limit' do it 'returns 200 KB for size_limit' do
...@@ -48,7 +48,7 @@ EOT ...@@ -48,7 +48,7 @@ EOT
context 'when the feature gitlab_git_diff_size_limit_increase is disabled' do context 'when the feature gitlab_git_diff_size_limit_increase is disabled' do
before do before do
Feature.disable('gitlab_git_diff_size_limit_increase') stub_feature_flags(gitlab_git_diff_size_limit_increase: false)
end end
it 'returns 100 KB for size_limit' do it 'returns 100 KB for size_limit' do
......
...@@ -59,6 +59,7 @@ RSpec.configure do |config| ...@@ -59,6 +59,7 @@ RSpec.configure do |config|
config.include ApiHelpers, :api config.include ApiHelpers, :api
config.include Gitlab::Routing, type: :routing config.include Gitlab::Routing, type: :routing
config.include MigrationsHelpers, :migration config.include MigrationsHelpers, :migration
config.include StubFeatureFlags
config.infer_spec_type_from_file_location! config.infer_spec_type_from_file_location!
...@@ -79,6 +80,8 @@ RSpec.configure do |config| ...@@ -79,6 +80,8 @@ RSpec.configure do |config|
config.before(:example) do config.before(:example) do
# Skip pre-receive hook check so we can use the web editor and merge. # Skip pre-receive hook check so we can use the web editor and merge.
allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, nil]) allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, nil])
# Enable all features by default for testing
allow(Feature).to receive(:enabled?) { true }
end end
config.before(:example, :request_store) do config.before(:example, :request_store) do
......
module StubFeatureFlags
def stub_feature_flags(features)
features.each do |feature_name, enabled|
allow(Feature).to receive(:enabled?).with(feature_name) { enabled }
allow(Feature).to receive(:enabled?).with(feature_name.to_s) { enabled }
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