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/models/application_setting_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/models/application_setting_spec.rb')
-rw-r--r--spec/models/application_setting_spec.rb111
1 files changed, 60 insertions, 51 deletions
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index 4b7281d593a..fb485d0b2c6 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -215,20 +215,27 @@ describe ApplicationSetting, models: true do
end
describe 'performance bar settings' do
- before do
- Flipper.unregister_groups
- Flipper.register(:performance_team)
- end
+ describe 'performance_bar_allowed_group_id=' do
+ context 'with a blank path' do
+ before do
+ setting.performance_bar_allowed_group_id = create(:group).full_path
+ end
- after do
- Flipper.unregister_groups
- end
+ it 'persists nil for a "" path and clears allowed user IDs cache' do
+ expect(Gitlab::PerformanceBar).to receive(:expire_allowed_user_ids_cache)
- describe 'performance_bar_allowed_group_id=' do
- it 'does not persist an invalid group path' do
- setting.performance_bar_allowed_group_id = 'foo'
+ setting.performance_bar_allowed_group_id = ''
+
+ expect(setting.performance_bar_allowed_group_id).to be_nil
+ end
+ end
+
+ context 'with an invalid path' do
+ it 'does not persist an invalid group path' do
+ setting.performance_bar_allowed_group_id = 'foo'
- expect(setting.performance_bar_allowed_group_id).to be_nil
+ expect(setting.performance_bar_allowed_group_id).to be_nil
+ end
end
context 'with a path to an existing group' do
@@ -243,14 +250,28 @@ describe ApplicationSetting, models: true do
end
context 'when the given path is the same' do
- before do
- setting.performance_bar_allowed_group_id = group.full_path
+ context 'with a blank path' do
+ before do
+ setting.performance_bar_allowed_group_id = nil
+ end
+
+ it 'clears the cached allowed user IDs' do
+ expect(Gitlab::PerformanceBar).not_to receive(:expire_allowed_user_ids_cache)
+
+ setting.performance_bar_allowed_group_id = ''
+ end
end
- it 'clears the cached allowed user IDs' do
- expect(Gitlab::PerformanceBar).not_to receive(:expire_allowed_user_ids_cache)
+ context 'with a valid path' do
+ before do
+ setting.performance_bar_allowed_group_id = group.full_path
+ end
+
+ it 'clears the cached allowed user IDs' do
+ expect(Gitlab::PerformanceBar).not_to receive(:expire_allowed_user_ids_cache)
- setting.performance_bar_allowed_group_id = group.full_path
+ setting.performance_bar_allowed_group_id = group.full_path
+ end
end
end
end
@@ -276,83 +297,71 @@ describe ApplicationSetting, models: true do
end
end
- describe 'performance_bar_enabled?' do
- context 'with the Performance Bar is enabled globally' do
- before do
- Feature.enable(:performance_bar)
- end
-
- it 'returns true' do
- expect(setting).to be_performance_bar_enabled
- end
- end
+ describe 'performance_bar_enabled' do
+ context 'with the Performance Bar is enabled' do
+ let(:group) { create(:group) }
- context 'with the Performance Bar is enabled for the performance_team group' do
before do
- Feature.enable_group(:performance_bar, :performance_team)
+ setting.performance_bar_allowed_group_id = group.full_path
end
it 'returns true' do
- expect(setting).to be_performance_bar_enabled
- end
- end
-
- context 'with the Performance Bar is enabled for a specific user' do
- before do
- Feature.enable(:performance_team, create(:user))
- end
-
- it 'returns false' do
- expect(setting).not_to be_performance_bar_enabled
+ expect(setting.performance_bar_enabled).to be_truthy
end
end
end
describe 'performance_bar_enabled=' do
context 'when the performance bar is enabled' do
+ let(:group) { create(:group) }
+
before do
- Feature.enable(:performance_bar)
+ setting.performance_bar_allowed_group_id = group.full_path
end
context 'when passing true' do
it 'does not clear allowed user IDs cache' do
expect(Gitlab::PerformanceBar).not_to receive(:expire_allowed_user_ids_cache)
+
setting.performance_bar_enabled = true
- expect(setting).to be_performance_bar_enabled
+ expect(setting.performance_bar_allowed_group_id).to eq(group.id)
+ expect(setting.performance_bar_enabled).to be_truthy
end
end
context 'when passing false' do
it 'disables the performance bar and clears allowed user IDs cache' do
expect(Gitlab::PerformanceBar).to receive(:expire_allowed_user_ids_cache)
+
setting.performance_bar_enabled = false
- expect(setting).not_to be_performance_bar_enabled
+ expect(setting.performance_bar_allowed_group_id).to be_nil
+ expect(setting.performance_bar_enabled).to be_falsey
end
end
end
context 'when the performance bar is disabled' do
- before do
- Feature.disable(:performance_bar)
- end
-
context 'when passing true' do
- it 'enables the performance bar and clears allowed user IDs cache' do
- expect(Gitlab::PerformanceBar).to receive(:expire_allowed_user_ids_cache)
+ it 'does nothing and does not clear allowed user IDs cache' do
+ expect(Gitlab::PerformanceBar).not_to receive(:expire_allowed_user_ids_cache)
+
setting.performance_bar_enabled = true
- expect(setting).to be_performance_bar_enabled
+ expect(setting.performance_bar_allowed_group_id).to be_nil
+ expect(setting.performance_bar_enabled).to be_falsey
end
end
context 'when passing false' do
- it 'does not clear allowed user IDs cache' do
+ it 'does nothing and does not clear allowed user IDs cache' do
expect(Gitlab::PerformanceBar).not_to receive(:expire_allowed_user_ids_cache)
+
setting.performance_bar_enabled = false
- expect(setting).not_to be_performance_bar_enabled
+ expect(setting.performance_bar_allowed_group_id).to be_nil
+ expect(setting.performance_bar_enabled).to be_falsey
end
end
end