2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-06-05 17:57:01 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-02-15 21:08:59 +00:00
|
|
|
RSpec.describe 'User visits the profile preferences page', :js do
|
2019-02-20 22:58:53 +00:00
|
|
|
include Select2Helper
|
|
|
|
|
2015-06-05 17:57:01 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2017-09-12 22:50:18 +00:00
|
|
|
|
|
|
|
visit(profile_preferences_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows correct menu item' do
|
2017-09-16 10:09:58 +00:00
|
|
|
expect(page).to have_active_navigation('Preferences')
|
2015-06-05 17:57:01 +00:00
|
|
|
end
|
|
|
|
|
2017-09-12 22:50:18 +00:00
|
|
|
describe 'User changes their syntax highlighting theme', :js do
|
2015-06-10 21:08:10 +00:00
|
|
|
it 'creates a flash message' do
|
|
|
|
choose 'user_color_scheme_id_5'
|
|
|
|
|
2017-08-08 14:45:52 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
2015-06-10 21:08:10 +00:00
|
|
|
expect_preferences_saved_message
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates their preference' do
|
|
|
|
choose 'user_color_scheme_id_5'
|
|
|
|
|
2017-08-08 14:45:52 +00:00
|
|
|
wait_for_requests
|
|
|
|
refresh
|
|
|
|
|
|
|
|
expect(page).to have_checked_field('user_color_scheme_id_5')
|
2015-06-10 21:08:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-12 22:50:18 +00:00
|
|
|
describe 'User changes their default dashboard', :js do
|
2015-06-10 21:08:10 +00:00
|
|
|
it 'creates a flash message' do
|
2019-08-14 21:12:38 +00:00
|
|
|
select2('stars', from: '#user_dashboard')
|
2021-02-15 21:08:59 +00:00
|
|
|
click_button 'Save changes'
|
2015-06-10 21:08:10 +00:00
|
|
|
|
2017-08-08 14:45:52 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
2015-06-10 21:08:10 +00:00
|
|
|
expect_preferences_saved_message
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates their preference' do
|
2019-08-14 21:12:38 +00:00
|
|
|
select2('stars', from: '#user_dashboard')
|
2021-02-15 21:08:59 +00:00
|
|
|
click_button 'Save changes'
|
2015-06-10 21:08:10 +00:00
|
|
|
|
2017-08-08 14:45:52 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
find('#logo').click
|
2016-08-11 16:48:32 +00:00
|
|
|
|
2017-08-08 14:45:52 +00:00
|
|
|
expect(page).to have_content("You don't have starred projects yet")
|
|
|
|
expect(page.current_path).to eq starred_dashboard_projects_path
|
2015-06-10 21:08:10 +00:00
|
|
|
|
2017-06-17 06:08:27 +00:00
|
|
|
find('.shortcuts-activity').click
|
2016-08-11 16:48:32 +00:00
|
|
|
|
2016-08-12 17:44:43 +00:00
|
|
|
expect(page).not_to have_content("You don't have starred projects yet")
|
2015-09-08 16:14:02 +00:00
|
|
|
expect(page.current_path).to eq dashboard_projects_path
|
2015-06-10 21:08:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-02-20 22:58:53 +00:00
|
|
|
describe 'User changes their language', :js do
|
2020-07-08 06:09:13 +00:00
|
|
|
it 'creates a flash message', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/31404' do
|
2019-02-20 22:58:53 +00:00
|
|
|
select2('en', from: '#user_preferred_language')
|
2021-02-15 21:08:59 +00:00
|
|
|
click_button 'Save changes'
|
2019-02-20 22:58:53 +00:00
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect_preferences_saved_message
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates their preference' do
|
|
|
|
wait_for_requests
|
2020-07-31 21:10:12 +00:00
|
|
|
select2('pt_BR', from: '#user_preferred_language')
|
2021-02-15 21:08:59 +00:00
|
|
|
click_button 'Save changes'
|
2019-02-20 22:58:53 +00:00
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
refresh
|
|
|
|
|
2020-07-31 21:10:12 +00:00
|
|
|
expect(page).to have_css('html[lang="pt-BR"]')
|
2019-02-20 22:58:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-01-06 15:07:26 +00:00
|
|
|
describe 'User changes whitespace in code' do
|
|
|
|
it 'updates their preference' do
|
|
|
|
expect(user.render_whitespace_in_code).to be(false)
|
|
|
|
expect(render_whitespace_field).not_to be_checked
|
|
|
|
render_whitespace_field.click
|
|
|
|
|
|
|
|
click_button 'Save changes'
|
|
|
|
|
2021-02-15 21:08:59 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
2020-01-06 15:07:26 +00:00
|
|
|
expect(user.reload.render_whitespace_in_code).to be(true)
|
|
|
|
expect(render_whitespace_field).to be_checked
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def render_whitespace_field
|
|
|
|
find_field('user[render_whitespace_in_code]')
|
|
|
|
end
|
|
|
|
|
2015-06-10 21:08:10 +00:00
|
|
|
def expect_preferences_saved_message
|
2015-06-19 02:13:32 +00:00
|
|
|
page.within('.flash-container') do
|
2015-06-10 21:08:10 +00:00
|
|
|
expect(page).to have_content('Preferences saved.')
|
2015-06-05 17:57:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|