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 15:56:50 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2018-05-04 14:54:43 +0300
commit10aa55a770c2985c22c92d17b8a7ea90b0a09085 (patch)
tree15b66bb5e3f26d0a49c07bf781c644deb998f0c8 /spec/controllers/users
parent65bea3f7d0bf30b5f9a9b3f94567474d3c8f7cbc (diff)
Allow a user to accept/decline terms
When a user accepts, we store this in the agreements to keep track of which terms they accepted. We also update the flag on the user.
Diffstat (limited to 'spec/controllers/users')
-rw-r--r--spec/controllers/users/terms_controller_spec.rb36
1 files changed, 35 insertions, 1 deletions
diff --git a/spec/controllers/users/terms_controller_spec.rb b/spec/controllers/users/terms_controller_spec.rb
index 74d17748093..50e818a4520 100644
--- a/spec/controllers/users/terms_controller_spec.rb
+++ b/spec/controllers/users/terms_controller_spec.rb
@@ -2,6 +2,7 @@ require 'spec_helper'
describe Users::TermsController do
let(:user) { create(:user) }
+ let(:term) { create(:term) }
before do
sign_in user
@@ -15,9 +16,42 @@ describe Users::TermsController do
end
it 'shows terms when they exist' do
- create(:term)
+ term
expect(response).to have_gitlab_http_status(:success)
end
end
+
+ describe 'POST #accept' do
+ it 'saves that the user accepted the terms' do
+ post :accept, id: term.id
+
+ agreement = user.term_agreements.find_by(term: term)
+
+ expect(agreement.accepted).to eq(true)
+ end
+
+ it 'redirects to a path when specified' do
+ post :accept, id: term.id, redirect: groups_path
+
+ expect(response).to redirect_to(groups_path)
+ end
+ end
+
+ describe 'POST #decline' do
+ it 'stores that the user declined the terms' do
+ post :decline, id: term.id
+
+ agreement = user.term_agreements.find_by(term: term)
+
+ expect(agreement.accepted).to eq(false)
+ end
+
+ it 'signs out the user' do
+ post :decline, id: term.id
+
+ expect(response).to redirect_to(root_path)
+ expect(assigns(:current_user)).to be_nil
+ end
+ end
end