diff options
author | Rémy Coutable <remy@rymai.me> | 2017-07-13 12:24:31 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-13 12:24:31 +0000 |
commit | a97208dde7b98dadc60882f93adfed779eff6bb2 (patch) | |
tree | 46fafb5508bd9914fe3f38c728946d0c25c83f5b | |
parent | e691f5b81207b03f88ec73434db49ee47fa93a4e (diff) | |
parent | 3ee48e422defaedd69946c607bd8d3672e510375 (diff) | |
download | gitlab-ce-a97208dde7b98dadc60882f93adfed779eff6bb2.tar.gz |
Merge branch 'bvl-enable-features-in-test' into 'master'
Enable all feature flags by default in specs
See merge request !12832
-rw-r--r-- | spec/features/merge_requests/conflicts_spec.rb | 5 | ||||
-rw-r--r-- | spec/features/projects/diffs/diff_show_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/git/diff_spec.rb | 4 | ||||
-rw-r--r-- | spec/spec_helper.rb | 3 | ||||
-rw-r--r-- | spec/support/stub_feature_flags.rb | 8 |
5 files changed, 22 insertions, 2 deletions
diff --git a/spec/features/merge_requests/conflicts_spec.rb b/spec/features/merge_requests/conflicts_spec.rb index 3e01ea69122..5c0909b6a59 100644 --- a/spec/features/merge_requests/conflicts_spec.rb +++ b/spec/features/merge_requests/conflicts_spec.rb @@ -4,6 +4,11 @@ feature 'Merge request conflict resolution', js: true, feature: true do let(:user) { create(:user) } 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) create(:merge_request, source_branch: source_branch, target_branch: 'conflict-start', source_project: project) do |mr| mr.mark_as_unmergeable diff --git a/spec/features/projects/diffs/diff_show_spec.rb b/spec/features/projects/diffs/diff_show_spec.rb index b528b283495..4baccb24806 100644 --- a/spec/features/projects/diffs/diff_show_spec.rb +++ b/spec/features/projects/diffs/diff_show_spec.rb @@ -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 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') end diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb index 0d712f39aea..7ea3386ac2a 100644 --- a/spec/lib/gitlab/git/diff_spec.rb +++ b/spec/lib/gitlab/git/diff_spec.rb @@ -34,7 +34,7 @@ EOT describe 'size limit feature toggles' do context 'when the feature gitlab_git_diff_size_limit_increase is enabled' do before do - Feature.enable('gitlab_git_diff_size_limit_increase') + stub_feature_flags(gitlab_git_diff_size_limit_increase: true) end it 'returns 200 KB for size_limit' do @@ -48,7 +48,7 @@ EOT context 'when the feature gitlab_git_diff_size_limit_increase is disabled' do before do - Feature.disable('gitlab_git_diff_size_limit_increase') + stub_feature_flags(gitlab_git_diff_size_limit_increase: false) end it 'returns 100 KB for size_limit' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3c142764e28..b8ed1e18de0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -59,6 +59,7 @@ RSpec.configure do |config| config.include ApiHelpers, :api config.include Gitlab::Routing, type: :routing config.include MigrationsHelpers, :migration + config.include StubFeatureFlags config.infer_spec_type_from_file_location! @@ -79,6 +80,8 @@ RSpec.configure do |config| config.before(:example) do # 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]) + # Enable all features by default for testing + allow(Feature).to receive(:enabled?) { true } end config.before(:example, :request_store) do diff --git a/spec/support/stub_feature_flags.rb b/spec/support/stub_feature_flags.rb new file mode 100644 index 00000000000..b96338bf548 --- /dev/null +++ b/spec/support/stub_feature_flags.rb @@ -0,0 +1,8 @@ +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 |