2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'User visits the profile preferences page' do
|
2019-07-07 11:18:12 +05:30
|
|
|
include Select2Helper
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
visit(profile_preferences_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows correct menu item' do
|
|
|
|
expect(page).to have_active_navigation('Preferences')
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe 'User changes their syntax highlighting theme', :js do
|
2015-09-11 14:41:01 +05:30
|
|
|
it 'creates a flash message' do
|
|
|
|
choose 'user_color_scheme_id_5'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
expect_preferences_saved_message
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates their preference' do
|
|
|
|
choose 'user_color_scheme_id_5'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
|
|
|
refresh
|
|
|
|
|
|
|
|
expect(page).to have_checked_field('user_color_scheme_id_5')
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe 'User changes their default dashboard', :js do
|
2015-09-11 14:41:01 +05:30
|
|
|
it 'creates a flash message' do
|
2019-10-12 21:52:04 +05:30
|
|
|
select2('stars', from: '#user_dashboard')
|
2015-09-11 14:41:01 +05:30
|
|
|
click_button 'Save'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
expect_preferences_saved_message
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates their preference' do
|
2019-10-12 21:52:04 +05:30
|
|
|
select2('stars', from: '#user_dashboard')
|
2015-09-11 14:41:01 +05:30
|
|
|
click_button 'Save'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
find('#logo').click
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(page).to have_content("You don't have starred projects yet")
|
|
|
|
expect(page.current_path).to eq starred_dashboard_projects_path
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
find('.shortcuts-activity').click
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
expect(page).not_to have_content("You don't have starred projects yet")
|
2015-09-25 12:07:36 +05:30
|
|
|
expect(page.current_path).to eq dashboard_projects_path
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
describe 'User changes their language', :js do
|
2020-07-28 23:09:34 +05:30
|
|
|
it 'creates a flash message', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/31404' do
|
2019-07-07 11:18:12 +05:30
|
|
|
select2('en', from: '#user_preferred_language')
|
|
|
|
click_button 'Save'
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect_preferences_saved_message
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates their preference' do
|
|
|
|
wait_for_requests
|
|
|
|
select2('eo', from: '#user_preferred_language')
|
|
|
|
click_button 'Save'
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
refresh
|
|
|
|
|
|
|
|
expect(page).to have_css('html[lang="eo"]')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
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'
|
|
|
|
|
|
|
|
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-09-11 14:41:01 +05:30
|
|
|
def expect_preferences_saved_message
|
|
|
|
page.within('.flash-container') do
|
|
|
|
expect(page).to have_content('Preferences saved.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|