2019-11-15 13:06:24 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 11:08:50 -04:00
|
|
|
RSpec.describe 'profiles/preferences/show' do
|
2019-11-15 13:06:24 -05:00
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
|
|
|
let_it_be(:user) { build(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
assign(:user, user)
|
|
|
|
allow(controller).to receive(:current_user).and_return(user)
|
|
|
|
end
|
|
|
|
|
2020-08-17 14:10:01 -04:00
|
|
|
context 'navigation theme' do
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has an id for anchoring' do
|
|
|
|
expect(rendered).to have_css('#navigation-theme')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'syntax highlighting theme' do
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has an id for anchoring' do
|
|
|
|
expect(rendered).to have_css('#syntax-highlighting-theme')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-01-06 10:07:26 -05:00
|
|
|
context 'behavior' do
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has option for Render whitespace characters in the Web IDE' do
|
|
|
|
expect(rendered).to have_unchecked_field('Render whitespace characters in the Web IDE')
|
|
|
|
end
|
2020-08-12 14:31:49 -04:00
|
|
|
|
2020-08-17 14:10:01 -04:00
|
|
|
it 'has an id for anchoring' do
|
2020-08-12 14:31:49 -04:00
|
|
|
expect(rendered).to have_css('#behavior')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has helpful homepage setup guidance' do
|
|
|
|
expect(rendered).to have_field('Homepage content')
|
|
|
|
expect(rendered).to have_content('Choose what content you want to see on your homepage.')
|
|
|
|
end
|
2020-01-06 10:07:26 -05:00
|
|
|
end
|
|
|
|
|
2020-08-17 14:10:01 -04:00
|
|
|
context 'localization' do
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has an id for anchoring' do
|
|
|
|
expect(rendered).to have_css('#localization')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-11-15 13:06:24 -05:00
|
|
|
context 'sourcegraph' do
|
|
|
|
def have_sourcegraph_field(*args)
|
|
|
|
have_field('user_sourcegraph_enabled', *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def have_integrations_section
|
2020-08-17 14:10:01 -04:00
|
|
|
have_css('#integrations.profile-settings-sidebar', { text: 'Integrations' })
|
2019-11-15 13:06:24 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
2020-06-02 08:08:33 -04:00
|
|
|
stub_feature_flags(sourcegraph: sourcegraph_feature)
|
2019-11-15 13:06:24 -05:00
|
|
|
stub_application_setting(sourcegraph_enabled: sourcegraph_enabled)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when not fully enabled' do
|
|
|
|
where(:feature, :admin_enabled) do
|
|
|
|
false | false
|
|
|
|
false | true
|
|
|
|
true | false
|
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
|
|
|
let(:sourcegraph_feature) { feature }
|
|
|
|
let(:sourcegraph_enabled) { admin_enabled }
|
|
|
|
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not display sourcegraph field' do
|
|
|
|
expect(rendered).not_to have_sourcegraph_field
|
|
|
|
end
|
|
|
|
|
2020-02-24 13:09:05 -05:00
|
|
|
it 'does not display Integration Settings' do
|
2019-11-15 13:06:24 -05:00
|
|
|
expect(rendered).not_to have_integrations_section
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when fully enabled' do
|
|
|
|
let(:sourcegraph_feature) { true }
|
|
|
|
let(:sourcegraph_enabled) { true }
|
|
|
|
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays the sourcegraph field' do
|
|
|
|
expect(rendered).to have_sourcegraph_field
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays the integrations section' do
|
|
|
|
expect(rendered).to have_integrations_section
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|