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:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-04-27 17:50:33 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2018-05-04 14:54:43 +0300
commit7684217d6806408cd338260119364419260d1720 (patch)
tree7b913d6c6c051a463d99ad286e2ac04a6b8d5632 /spec/controllers/users
parent10aa55a770c2985c22c92d17b8a7ea90b0a09085 (diff)
Enforces terms in the web application
This enforces the terms in the web application. These cases are specced: - Logging in: When terms are enforced, and a user logs in that has not accepted the terms, they are presented with the screen. They get directed to their customized root path afterwards. - Signing up: After signing up, the first screen the user is presented with the screen to accept the terms. After they accept they are directed to the dashboard. - While a session is active: - For a GET: The user will be directed to the terms page first, after they accept the terms, they will be directed to the page they were going to - For any other request: They are directed to the terms, after they accept the terms, they are directed back to the page they came from to retry the request. Any information entered would be persisted in localstorage and available on the page.
Diffstat (limited to 'spec/controllers/users')
-rw-r--r--spec/controllers/users/terms_controller_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/controllers/users/terms_controller_spec.rb b/spec/controllers/users/terms_controller_spec.rb
index 50e818a4520..a744463413c 100644
--- a/spec/controllers/users/terms_controller_spec.rb
+++ b/spec/controllers/users/terms_controller_spec.rb
@@ -36,6 +36,30 @@ describe Users::TermsController do
expect(response).to redirect_to(groups_path)
end
+
+ it 'redirects to the referer when no redirect specified' do
+ request.env["HTTP_REFERER"] = groups_url
+
+ post :accept, id: term.id
+
+ expect(response).to redirect_to(groups_path)
+ end
+
+ context 'redirecting to another domain' do
+ it 'is prevented when passing a redirect param' do
+ post :accept, id: term.id, redirect: '//example.com/random/path'
+
+ expect(response).to redirect_to(root_path)
+ end
+
+ it 'is prevented when redirecting to the referer' do
+ request.env["HTTP_REFERER"] = 'http://example.com/and/a/path'
+
+ post :accept, id: term.id
+
+ expect(response).to redirect_to(root_path)
+ end
+ end
end
describe 'POST #decline' do