2018-04-26 07:28:24 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'Users > Terms' do
|
2018-04-27 10:50:33 -04:00
|
|
|
include TermsHelper
|
|
|
|
|
2018-04-26 07:28:24 -04:00
|
|
|
let!(:term) { create(:term, terms: 'By accepting, you promise to be nice!') }
|
|
|
|
|
|
|
|
before do
|
2018-04-27 08:56:50 -04:00
|
|
|
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
|
2018-04-26 07:28:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the terms' do
|
2018-04-27 08:56:50 -04:00
|
|
|
visit terms_path
|
|
|
|
|
2018-04-26 07:28:24 -04:00
|
|
|
expect(page).to have_content('By accepting, you promise to be nice!')
|
|
|
|
end
|
2018-04-27 08:56:50 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
it 'does not show buttons to accept, decline or sign out', :aggregate_failures do
|
|
|
|
visit terms_path
|
|
|
|
|
|
|
|
expect(page).not_to have_css('.footer-block')
|
|
|
|
expect(page).not_to have_content('Accept terms')
|
|
|
|
expect(page).not_to have_content('Decline and sign out')
|
|
|
|
expect(page).not_to have_content('Continue')
|
|
|
|
end
|
2018-04-27 08:56:50 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
context 'when signed in' do
|
|
|
|
let(:user) { create(:user) }
|
2018-04-27 08:56:50 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
2018-04-27 08:56:50 -04:00
|
|
|
end
|
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
context 'declining the terms' do
|
|
|
|
it 'returns the user to the app' do
|
|
|
|
visit terms_path
|
2018-04-27 08:56:50 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
click_button 'Decline and sign out'
|
2018-04-27 08:56:50 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
expect(page).not_to have_content(term.terms)
|
|
|
|
expect(user.reload.terms_accepted?).to be(false)
|
|
|
|
end
|
2018-04-27 08:56:50 -04:00
|
|
|
end
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
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
|
2018-05-25 19:17:57 -04:00
|
|
|
end
|
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
context 'when the user has already accepted the terms' do
|
|
|
|
before do
|
|
|
|
accept_terms(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows the user to continue to the app' do
|
|
|
|
visit terms_path
|
2018-05-25 19:17:57 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
expect(page).to have_content "You have already accepted the Terms of Service as #{user.to_reference}"
|
2018-05-25 19:17:57 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
click_link 'Continue'
|
2018-05-25 19:17:57 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
expect(current_path).to eq(root_path)
|
|
|
|
end
|
2018-05-25 19:17:57 -04:00
|
|
|
end
|
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
context 'terms were enforced while session is active', :js do
|
|
|
|
let(:project) { create(:project) }
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
end
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2019-01-16 07:09:29 -05:00
|
|
|
it 'redirects to terms and back to where the user was going' do
|
2018-06-08 07:20:44 -04:00
|
|
|
visit project_path(project)
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
enforce_terms
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2019-07-01 19:44:54 -04:00
|
|
|
# Application settings are cached for a minute
|
|
|
|
Timecop.travel 2.minutes do
|
|
|
|
within('.nav-sidebar') do
|
|
|
|
click_link 'Issues'
|
|
|
|
end
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2019-07-01 19:44:54 -04:00
|
|
|
expect_to_be_on_terms_page
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2019-07-01 19:44:54 -04:00
|
|
|
click_button('Accept terms')
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2019-07-01 19:44:54 -04:00
|
|
|
expect(current_path).to eq(project_issues_path(project))
|
|
|
|
end
|
2018-06-08 07:20:44 -04:00
|
|
|
end
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
# Disabled until https://gitlab.com/gitlab-org/gitlab-ce/issues/37162 is solved properly
|
|
|
|
xit 'redirects back to the page the user was trying to save' do
|
|
|
|
visit new_project_issue_path(project)
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
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"
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
enforce_terms
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
click_button 'Submit issue'
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
expect(current_path).to eq(terms_path)
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
click_button('Accept terms')
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
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
|
2018-04-27 10:50:33 -04:00
|
|
|
end
|
2018-05-10 05:35:02 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
context 'when the terms are enforced' do
|
|
|
|
before do
|
|
|
|
enforce_terms
|
|
|
|
end
|
2018-05-10 05:35:02 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
context 'signing out', :js do
|
|
|
|
it 'allows the user to sign out without a response' do
|
|
|
|
visit terms_path
|
2018-05-10 05:35:02 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
find('.header-user-dropdown-toggle').click
|
|
|
|
click_link('Sign out')
|
2018-05-10 05:35:02 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
expect(page).to have_content('Sign in')
|
|
|
|
expect(page).to have_content('Register')
|
|
|
|
end
|
2018-05-10 05:35:02 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-04-26 07:28:24 -04:00
|
|
|
end
|