diff options
author | Douwe Maan <douwe@gitlab.com> | 2019-06-18 15:25:26 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2019-06-18 15:25:26 +0300 |
commit | 14d46afd9b3ee7482fa8be7bc6782b19e960ce45 (patch) | |
tree | 55bf0f0426481ab68d985e68c29eec711a199216 /spec | |
parent | 6d68a3a254833ada6228bf245fc43bb8f4d6b85b (diff) | |
parent | 4dfaaf40b9c6754157adff3704a8036b440148b3 (diff) |
Merge branch 'zj-feature-flag-default-on-catfile-cache' into 'master'
Feature flag default on catfile cache
Closes gitaly#1712
See merge request gitlab-org/gitlab-ce!29556
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/feature/gitaly_spec.rb | 40 | ||||
-rw-r--r-- | spec/lib/gitlab/gitaly_client/storage_settings_spec.rb | 12 | ||||
-rw-r--r-- | spec/lib/gitlab/gitaly_client_spec.rb | 14 | ||||
-rw-r--r-- | spec/support/helpers/cycle_analytics_helpers.rb | 2 |
4 files changed, 49 insertions, 19 deletions
diff --git a/spec/lib/feature/gitaly_spec.rb b/spec/lib/feature/gitaly_spec.rb new file mode 100644 index 00000000000..0e24a927d4c --- /dev/null +++ b/spec/lib/feature/gitaly_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe Feature::Gitaly do + let(:feature_flag) { "mep_mep" } + + before do + stub_const("#{described_class}::SERVER_FEATURE_FLAGS", [feature_flag]) + end + + describe ".enabled?" do + context 'when the gate is closed' do + before do + stub_feature_flags(gitaly_mep_mep: false) + end + + it 'returns false' do + expect(described_class.enabled?(feature_flag)).to be(false) + end + end + + context 'when the flag defaults to on' do + it 'returns true' do + expect(described_class.enabled?(feature_flag)).to be(true) + end + end + end + + describe ".server_feature_flags" do + context 'when one flag is disabled' do + before do + stub_feature_flags(gitaly_mep_mep: false) + end + + subject { described_class.server_feature_flags } + + it { is_expected.to be_a(Hash) } + it { is_expected.to eq("gitaly-feature-mep-mep" => "false") } + end + end +end diff --git a/spec/lib/gitlab/gitaly_client/storage_settings_spec.rb b/spec/lib/gitlab/gitaly_client/storage_settings_spec.rb index bb10be2a4dc..f2f53982b09 100644 --- a/spec/lib/gitlab/gitaly_client/storage_settings_spec.rb +++ b/spec/lib/gitlab/gitaly_client/storage_settings_spec.rb @@ -28,12 +28,16 @@ describe Gitlab::GitalyClient::StorageSettings do end describe '.disk_access_denied?' do - it 'return false when Rugged is enabled', :enable_rugged do - expect(described_class.disk_access_denied?).to be_falsey + context 'when Rugged is enabled', :enable_rugged do + it 'returns false' do + expect(described_class.disk_access_denied?).to be_falsey + end end - it 'returns true' do - expect(described_class.disk_access_denied?).to be_truthy + context 'when Rugged is disabled' do + it 'returns true' do + expect(described_class.disk_access_denied?).to be_truthy + end end end end diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb index da1eb0c2618..eed233f1f3e 100644 --- a/spec/lib/gitlab/gitaly_client_spec.rb +++ b/spec/lib/gitlab/gitaly_client_spec.rb @@ -330,20 +330,6 @@ describe Gitlab::GitalyClient do end end - describe 'feature_enabled?' do - let(:feature_name) { 'my_feature' } - let(:real_feature_name) { "gitaly_#{feature_name}" } - - before do - allow(Feature).to receive(:enabled?).and_return(false) - end - - it 'returns false' do - expect(Feature).to receive(:enabled?).with(real_feature_name) - expect(described_class.feature_enabled?(feature_name)).to be(false) - end - end - describe 'timeouts' do context 'with default values' do before do diff --git a/spec/support/helpers/cycle_analytics_helpers.rb b/spec/support/helpers/cycle_analytics_helpers.rb index 33648292037..100e439ef44 100644 --- a/spec/support/helpers/cycle_analytics_helpers.rb +++ b/spec/support/helpers/cycle_analytics_helpers.rb @@ -10,7 +10,7 @@ module CycleAnalyticsHelpers repository = project.repository oldrev = repository.commit(branch_name)&.sha || Gitlab::Git::BLANK_SHA - if Timecop.frozen? && Gitlab::GitalyClient.feature_enabled?(:operation_user_commit_files) + if Timecop.frozen? mock_gitaly_multi_action_dates(repository, commit_time) end |