summaryrefslogtreecommitdiff
path: root/spec/features/users/terms_spec.rb
diff options
context:
space:
mode:
authorClement Ho <ClemMakesApps@gmail.com>2018-05-08 10:49:30 -0500
committerClement Ho <ClemMakesApps@gmail.com>2018-05-08 10:49:30 -0500
commit5955caed321e242bfebe52a4b47346a01a50e4f6 (patch)
treed9710c0732ce21801b4a79a281bec0bd39582a95 /spec/features/users/terms_spec.rb
parentf9e2b4730f58ba630344c9554eb907ab003abbd5 (diff)
parent533593e95cd3a922a2ec2ea43b345862361dfd67 (diff)
downloadgitlab-ce-5955caed321e242bfebe52a4b47346a01a50e4f6.tar.gz
Merge branch 'master' into bootstrap4
Diffstat (limited to 'spec/features/users/terms_spec.rb')
-rw-r--r--spec/features/users/terms_spec.rb84
1 files changed, 84 insertions, 0 deletions
diff --git a/spec/features/users/terms_spec.rb b/spec/features/users/terms_spec.rb
new file mode 100644
index 00000000000..bf6b5fa3d6a
--- /dev/null
+++ b/spec/features/users/terms_spec.rb
@@ -0,0 +1,84 @@
+require 'spec_helper'
+
+describe 'Users > Terms' do
+ include TermsHelper
+
+ let(:user) { create(:user) }
+ let!(:term) { create(:term, terms: 'By accepting, you promise to be nice!') }
+
+ before do
+ stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ sign_in(user)
+ end
+
+ it 'shows the terms' do
+ visit terms_path
+
+ expect(page).to have_content('By accepting, you promise to be nice!')
+ end
+
+ context 'declining the terms' do
+ it 'returns the user to the app' do
+ visit terms_path
+
+ click_button 'Decline and sign out'
+
+ expect(page).not_to have_content(term.terms)
+ expect(user.reload.terms_accepted?).to be(false)
+ end
+ end
+
+ context 'accepting the terms' do
+ it 'returns the user to the app' do
+ visit terms_path
+
+ click_button 'Accept terms'
+
+ expect(page).not_to have_content(term.terms)
+ expect(user.reload.terms_accepted?).to be(true)
+ end
+ end
+
+ context 'terms were enforced while session is active', :js do
+ let(:project) { create(:project) }
+
+ before do
+ project.add_developer(user)
+ end
+
+ it 'redirects to terms and back to where the user was going' do
+ visit project_path(project)
+
+ enforce_terms
+
+ within('.nav-sidebar') do
+ click_link 'Issues'
+ end
+
+ expect_to_be_on_terms_page
+
+ click_button('Accept terms')
+
+ expect(current_path).to eq(project_issues_path(project))
+ end
+
+ it 'redirects back to the page the user was trying to save' do
+ visit new_project_issue_path(project)
+
+ fill_in :issue_title, with: 'Hello world, a new issue'
+ fill_in :issue_description, with: "We don't want to lose what the user typed"
+
+ enforce_terms
+
+ click_button 'Submit issue'
+
+ expect(current_path).to eq(terms_path)
+
+ click_button('Accept terms')
+
+ expect(current_path).to eq(new_project_issue_path(project))
+ expect(find_field('issue_title').value).to eq('Hello world, a new issue')
+ expect(find_field('issue_description').value).to eq("We don't want to lose what the user typed")
+ end
+ end
+end