diff options
author | Robert Speicher <rspeicher@gmail.com> | 2018-04-02 14:17:17 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2018-04-02 14:19:19 -0500 |
commit | eb9e09bb1a9943b6ec7d326db6b8d6261fe2deb8 (patch) | |
tree | e159fe14b83be5d69437beec273cf95090fb1c41 | |
parent | 2f17b4cb78ab8c687675d78f675701a562c44b9e (diff) | |
download | gitlab-ce-rs-performance-bar-for-admins.tar.gz |
Always allow the performance bar to be enabled for adminsrs-performance-bar-for-admins
-rw-r--r-- | lib/gitlab/performance_bar.rb | 1 | ||||
-rw-r--r-- | spec/lib/gitlab/performance_bar_spec.rb | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/gitlab/performance_bar.rb b/lib/gitlab/performance_bar.rb index 6c2b2036074..92a308a12dc 100644 --- a/lib/gitlab/performance_bar.rb +++ b/lib/gitlab/performance_bar.rb @@ -5,6 +5,7 @@ module Gitlab def self.enabled?(user = nil) return true if Rails.env.development? + return true if user&.admin? return false unless user && allowed_group_id allowed_user_ids.include?(user.id) diff --git a/spec/lib/gitlab/performance_bar_spec.rb b/spec/lib/gitlab/performance_bar_spec.rb index b8a2267f1a4..f480376acb4 100644 --- a/spec/lib/gitlab/performance_bar_spec.rb +++ b/spec/lib/gitlab/performance_bar_spec.rb @@ -25,6 +25,12 @@ describe Gitlab::PerformanceBar do expect(described_class.enabled?(nil)).to be_falsy end + it 'returns true when given user is an admin' do + user = build_stubbed(:user, :admin) + + expect(described_class.enabled?(user)).to be_truthy + end + it 'returns false when allowed_group_id is nil' do expect(described_class).to receive(:allowed_group_id).and_return(nil) |