2015-06-05 17:57:01 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-06-28 20:19:52 +00:00
|
|
|
describe 'Profile > Preferences', feature: true do
|
2015-06-05 17:57:01 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
login_as(user)
|
2015-06-10 21:08:10 +00:00
|
|
|
visit profile_preferences_path
|
2015-06-05 17:57:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'User changes their application theme', js: true do
|
2015-06-05 19:50:36 +00:00
|
|
|
let(:default) { Gitlab::Themes.default }
|
|
|
|
let(:theme) { Gitlab::Themes.by_id(5) }
|
2015-06-05 17:57:01 +00:00
|
|
|
|
2015-06-10 21:08:10 +00:00
|
|
|
it 'creates a flash message' do
|
|
|
|
choose "user_theme_id_#{theme.id}"
|
|
|
|
|
|
|
|
expect_preferences_saved_message
|
2015-06-05 17:57:01 +00:00
|
|
|
end
|
|
|
|
|
2015-06-10 21:08:10 +00:00
|
|
|
it 'updates their preference' do
|
2015-06-05 22:01:45 +00:00
|
|
|
choose "user_theme_id_#{theme.id}"
|
|
|
|
|
2015-06-15 00:33:29 +00:00
|
|
|
allowing_for_delay do
|
|
|
|
visit page.current_path
|
|
|
|
expect(page).to have_checked_field("user_theme_id_#{theme.id}")
|
|
|
|
end
|
2015-06-05 22:01:45 +00:00
|
|
|
end
|
|
|
|
|
2015-06-05 19:50:36 +00:00
|
|
|
it 'reflects the changes immediately' do
|
2015-06-05 17:57:01 +00:00
|
|
|
expect(page).to have_selector("body.#{default.css_class}")
|
|
|
|
|
|
|
|
choose "user_theme_id_#{theme.id}"
|
|
|
|
|
|
|
|
expect(page).not_to have_selector("body.#{default.css_class}")
|
|
|
|
expect(page).to have_selector("body.#{theme.css_class}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-10 21:08:10 +00:00
|
|
|
describe 'User changes their syntax highlighting theme', js: true do
|
|
|
|
it 'creates a flash message' do
|
|
|
|
choose 'user_color_scheme_id_5'
|
|
|
|
|
|
|
|
expect_preferences_saved_message
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates their preference' do
|
|
|
|
choose 'user_color_scheme_id_5'
|
|
|
|
|
2015-06-15 00:33:29 +00:00
|
|
|
allowing_for_delay do
|
|
|
|
visit page.current_path
|
|
|
|
expect(page).to have_checked_field('user_color_scheme_id_5')
|
|
|
|
end
|
2015-06-10 21:08:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-10 20:08:13 +00:00
|
|
|
describe 'User changes their default dashboard', js: true do
|
2015-06-10 21:08:10 +00:00
|
|
|
it 'creates a flash message' do
|
|
|
|
select 'Starred Projects', from: 'user_dashboard'
|
|
|
|
click_button 'Save'
|
|
|
|
|
|
|
|
expect_preferences_saved_message
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates their preference' do
|
|
|
|
select 'Starred Projects', from: 'user_dashboard'
|
|
|
|
click_button 'Save'
|
|
|
|
|
2016-06-10 20:08:13 +00:00
|
|
|
allowing_for_delay do
|
|
|
|
find('#logo').click
|
2016-08-11 16:48:32 +00:00
|
|
|
|
2016-08-12 17:44:43 +00:00
|
|
|
expect(page).to have_content("You don't have starred projects yet")
|
2016-06-10 20:08:13 +00:00
|
|
|
expect(page.current_path).to eq starred_dashboard_projects_path
|
|
|
|
end
|
2015-06-10 21:08:10 +00:00
|
|
|
|
|
|
|
click_link 'Your Projects'
|
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
|
|
|
|
|
|
|
|
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
|