summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-05-11 17:15:43 +0000
committerNick Thomas <nick@gitlab.com>2018-05-11 17:15:43 +0000
commitaa3004c48d6062c4f6f0dcaad91a9774445966e8 (patch)
tree7f12dc000e3af404d754ad34705bff99527cdaef
parentda49a357da7926f1ce14edb5a0a4dcc9be751080 (diff)
parenta5cb2fe2e09b9b758905693360ecc680ff4afe2a (diff)
downloadgitlab-ce-aa3004c48d6062c4f6f0dcaad91a9774445966e8.tar.gz
Merge branch 'bvl-fix-sign-out-on-terms' into 'master'
Allow a user to sign out when on the terms page Closes #46211 See merge request gitlab-org/gitlab-ce!18875
-rw-r--r--app/controllers/application_controller.rb9
-rw-r--r--spec/features/users/terms_spec.rb18
2 files changed, 25 insertions, 2 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 2caffec66ac..2843d70c645 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -13,8 +13,7 @@ class ApplicationController < ActionController::Base
before_action :authenticate_sessionless_user!
before_action :authenticate_user!
- before_action :enforce_terms!, if: -> { Gitlab::CurrentSettings.current_application_settings.enforce_terms },
- unless: :peek_request?
+ before_action :enforce_terms!, if: :should_enforce_terms?
before_action :validate_user_service_ticket!
before_action :check_password_expiration
before_action :ldap_security_check
@@ -373,4 +372,10 @@ class ApplicationController < ActionController::Base
def peek_request?
request.path.start_with?('/-/peek')
end
+
+ def should_enforce_terms?
+ return false unless Gitlab::CurrentSettings.current_application_settings.enforce_terms
+
+ !(peek_request? || devise_controller?)
+ end
end
diff --git a/spec/features/users/terms_spec.rb b/spec/features/users/terms_spec.rb
index bf6b5fa3d6a..f9469adbfe3 100644
--- a/spec/features/users/terms_spec.rb
+++ b/spec/features/users/terms_spec.rb
@@ -81,4 +81,22 @@ describe 'Users > Terms' do
expect(find_field('issue_description').value).to eq("We don't want to lose what the user typed")
end
end
+
+ context 'when the terms are enforced' do
+ before do
+ enforce_terms
+ end
+
+ context 'signing out', :js do
+ it 'allows the user to sign out without a response' do
+ visit terms_path
+
+ find('.header-user-dropdown-toggle').click
+ click_link('Sign out')
+
+ expect(page).to have_content('Sign in')
+ expect(page).to have_content('Register')
+ end
+ end
+ end
end