summaryrefslogtreecommitdiff
path: root/spec/controllers/concerns
diff options
context:
space:
mode:
authorJames Fargher <proglottis@gmail.com>2019-05-02 13:07:38 +1200
committerJames Fargher <proglottis@gmail.com>2019-05-07 08:37:04 +1200
commitbeb66cfcba26d0796644ccce2dfac8c65a808144 (patch)
tree6bb32fccb64f91776e946d84c5717d1ae52a9d7e /spec/controllers/concerns
parent8db382b05545fdef0a60bcff65f8c23e8b1ed282 (diff)
downloadgitlab-ce-beb66cfcba26d0796644ccce2dfac8c65a808144.tar.gz
Check instance cluster feature at policy level
Try to simplify feature flag checks by using policies
Diffstat (limited to 'spec/controllers/concerns')
-rw-r--r--spec/controllers/concerns/enforces_admin_authentication_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/controllers/concerns/enforces_admin_authentication_spec.rb b/spec/controllers/concerns/enforces_admin_authentication_spec.rb
new file mode 100644
index 00000000000..9025293f9ea
--- /dev/null
+++ b/spec/controllers/concerns/enforces_admin_authentication_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe EnforcesAdminAuthentication do
+ let(:user) { create(:user) }
+
+ before do
+ sign_in(user)
+ end
+
+ controller(ApplicationController) do
+ # `described_class` is not available in this context
+ include EnforcesAdminAuthentication # rubocop:disable RSpec/DescribedClass
+
+ def index
+ head :ok
+ end
+ end
+
+ describe 'authenticate_admin!' do
+ context 'as an admin' do
+ let(:user) { create(:admin) }
+
+ it 'renders ok' do
+ get :index
+ expect(response).to have_gitlab_http_status(200)
+ end
+ end
+
+ context 'as a user' do
+ it 'renders a 404' do
+ get :index
+ expect(response).to have_gitlab_http_status(404)
+ end
+ end
+ end
+end