Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-07-07 03:34:51 +0300
committerRémy Coutable <remy@rymai.me>2017-07-07 03:34:51 +0300
commit97611c88fcbae6b025750e6ebf2061a3d87d9753 (patch)
tree1d4ff635a807a49f99af219dc83c265a3465a4a6 /spec/lib/gitlab/performance_bar_spec.rb
parent040eeb1039b4298ea56a670a0a4ae511288806d6 (diff)
Don't use Flipper for the Performance Bar
The implementation now simply rely on the `performance_bar_allowed_group_id` Application Setting. Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/lib/gitlab/performance_bar_spec.rb')
-rw-r--r--spec/lib/gitlab/performance_bar_spec.rb66
1 files changed, 28 insertions, 38 deletions
diff --git a/spec/lib/gitlab/performance_bar_spec.rb b/spec/lib/gitlab/performance_bar_spec.rb
index e77a1ebbb0d..8a586bdbf63 100644
--- a/spec/lib/gitlab/performance_bar_spec.rb
+++ b/spec/lib/gitlab/performance_bar_spec.rb
@@ -1,65 +1,55 @@
require 'spec_helper'
describe Gitlab::PerformanceBar do
- describe '.enabled?' do
- it 'returns false when given actor is nil' do
- expect(described_class.enabled?(nil)).to be_falsy
- end
-
- it 'returns false when feature is disabled' do
- actor = double('actor')
-
- expect(Feature).to receive(:enabled?)
- .with(:performance_bar, actor).and_return(false)
-
- expect(described_class.enabled?(actor)).to be_falsy
- end
-
- it 'returns true when feature is enabled' do
- actor = double('actor')
-
- expect(Feature).to receive(:enabled?)
- .with(:performance_bar, actor).and_return(true)
-
- expect(described_class.enabled?(actor)).to be_truthy
- end
- end
-
- shared_examples 'allowed user IDs are cached in Redis for 10 minutes' do
+ shared_examples 'allowed user IDs are cached' do
before do
# Warm the Redis cache
- described_class.allowed_user?(user)
+ described_class.enabled?(user)
end
it 'caches the allowed user IDs in cache', :caching do
expect do
- expect(described_class.allowed_user?(user)).to be_truthy
+ expect(described_class.enabled?(user)).to be_truthy
end.not_to exceed_query_limit(0)
end
end
- describe '.allowed_user?' do
+ describe '.enabled?' do
let(:user) { create(:user) }
before do
- stub_performance_bar_setting(allowed_group: 'my-group')
+ stub_application_setting(performance_bar_allowed_group_id: -1)
+ end
+
+ it 'returns false when given user is nil' do
+ expect(described_class.enabled?(nil)).to be_falsy
end
- context 'when allowed group does not exist' do
+ it 'returns false when allowed_group_id is nil' do
+ expect(described_class).to receive(:allowed_group_id).and_return(nil)
+
+ expect(described_class.enabled?(user)).to be_falsy
+ end
+
+ context 'when allowed group ID does not exist' do
it 'returns false' do
- expect(described_class.allowed_user?(user)).to be_falsy
+ expect(described_class.enabled?(user)).to be_falsy
end
end
context 'when allowed group exists' do
let!(:my_group) { create(:group, path: 'my-group') }
+ before do
+ stub_application_setting(performance_bar_allowed_group_id: my_group.id)
+ end
+
context 'when user is not a member of the allowed group' do
it 'returns false' do
- expect(described_class.allowed_user?(user)).to be_falsy
+ expect(described_class.enabled?(user)).to be_falsy
end
- it_behaves_like 'allowed user IDs are cached in Redis for 10 minutes'
+ it_behaves_like 'allowed user IDs are cached'
end
context 'when user is a member of the allowed group' do
@@ -68,10 +58,10 @@ describe Gitlab::PerformanceBar do
end
it 'returns true' do
- expect(described_class.allowed_user?(user)).to be_truthy
+ expect(described_class.enabled?(user)).to be_truthy
end
- it_behaves_like 'allowed user IDs are cached in Redis for 10 minutes'
+ it_behaves_like 'allowed user IDs are cached'
end
end
@@ -81,11 +71,11 @@ describe Gitlab::PerformanceBar do
before do
create(:group, path: 'my-group')
nested_my_group.add_developer(user)
- stub_performance_bar_setting(allowed_group: 'my-org/my-group')
+ stub_application_setting(performance_bar_allowed_group_id: nested_my_group.id)
end
it 'returns the nested group' do
- expect(described_class.allowed_user?(user)).to be_truthy
+ expect(described_class.enabled?(user)).to be_truthy
end
end
@@ -95,7 +85,7 @@ describe Gitlab::PerformanceBar do
end
it 'returns false' do
- expect(described_class.allowed_user?(user)).to be_falsy
+ expect(described_class.enabled?(user)).to be_falsy
end
end
end