admin_settings_spec.rb 4.47 KB
Newer Older
1
2
require 'spec_helper'

3
feature 'Admin updates settings' do
4
5
6
7
  include StubENV

  before do
    stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
8
    sign_in(create(:admin))
9
10
11
    visit admin_application_settings_path
  end

12
  scenario 'Change visibility settings' do
Toon Claes's avatar
Toon Claes committed
13
    choose "application_setting_default_project_visibility_20"
14
15
16
17
18
    click_button 'Save'

    expect(page).to have_content "Application settings saved successfully"
  end

19
20
21
22
23
24
25
26
27
28
29
30
31
  scenario 'Uncheck all restricted visibility levels' do
    find('#application_setting_visibility_level_0').set(false)
    find('#application_setting_visibility_level_10').set(false)
    find('#application_setting_visibility_level_20').set(false)

    click_button 'Save'

    expect(page).to have_content "Application settings saved successfully"
    expect(find('#application_setting_visibility_level_0')).not_to be_checked
    expect(find('#application_setting_visibility_level_10')).not_to be_checked
    expect(find('#application_setting_visibility_level_20')).not_to be_checked
  end

32
33
34
35
  scenario 'Change application settings' do
    uncheck 'Gravatar enabled'
    fill_in 'Home page URL', with: 'https://about.gitlab.com/'
    fill_in 'Help page text', with: 'Example text'
36
37
    check 'Hide marketing-related entries from help'
    fill_in 'Support page URL', with: 'http://example.com/help'
38
    uncheck 'Project export enabled'
39
40
41
42
    click_button 'Save'

    expect(current_application_settings.gravatar_enabled).to be_falsey
    expect(current_application_settings.home_page_url).to eq "https://about.gitlab.com/"
43
44
45
    expect(current_application_settings.help_page_text).to eq "Example text"
    expect(current_application_settings.help_page_hide_commercial_content).to be_truthy
    expect(current_application_settings.help_page_support_url).to eq "http://example.com/help"
46
    expect(current_application_settings.project_export_enabled).to be_falsey
47
48
49
    expect(page).to have_content "Application settings saved successfully"
  end

Kamil Trzcinski's avatar
Kamil Trzcinski committed
50
  scenario 'Change Slack Notifications Service template settings' do
51
    first(:link, 'Service Templates').click
Kamil Trzcinski's avatar
Kamil Trzcinski committed
52
    click_link 'Slack notifications'
53
54
55
    fill_in 'Webhook', with: 'http://localhost'
    fill_in 'Username', with: 'test_user'
    fill_in 'service_push_channel', with: '#test_channel'
Kamil Trzciński's avatar
Kamil Trzciński committed
56
    page.check('Notify only broken pipelines')
57
    page.check('Notify only default branch')
58
59
60
61
62
63

    check_all_events
    click_on 'Save'

    expect(page).to have_content 'Application settings saved successfully'

Kamil Trzcinski's avatar
Kamil Trzcinski committed
64
    click_link 'Slack notifications'
65
66
67
68
69
70
71
72
73

    page.all('input[type=checkbox]').each do |checkbox|
      expect(checkbox).to be_checked
    end
    expect(find_field('Webhook').value).to eq 'http://localhost'
    expect(find_field('Username').value).to eq 'test_user'
    expect(find('#service_push_channel').value).to eq '#test_channel'
  end

74
75
76
  context 'sign-in restrictions', :js do
    it 'de-activates oauth sign-in source' do
      find('.btn', text: 'GitLab.com').click
77

78
79
80
81
      expect(find('.btn', text: 'GitLab.com')).not_to have_css('.active')
    end
  end

82
  scenario 'Change Keys settings' do
83
84
85
86
    select 'Are forbidden', from: 'RSA SSH keys'
    select 'Are allowed', from: 'DSA SSH keys'
    select 'Must be at least 384 bits', from: 'ECDSA SSH keys'
    select 'Are forbidden', from: 'ED25519 SSH keys'
87
88
    click_on 'Save'

89
90
    forbidden = ApplicationSetting::FORBIDDEN_KEY_VALUE.to_s

91
    expect(page).to have_content 'Application settings saved successfully'
92
93
94
95
    expect(find_field('RSA SSH keys').value).to eq(forbidden)
    expect(find_field('DSA SSH keys').value).to eq('0')
    expect(find_field('ECDSA SSH keys').value).to eq('384')
    expect(find_field('ED25519 SSH keys').value).to eq(forbidden)
96
97
  end

98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
  scenario 'Change Performance Bar settings' do
    group = create(:group)

    check 'Enable the Performance Bar'
    fill_in 'Allowed group', with: group.path

    click_on 'Save'

    expect(page).to have_content 'Application settings saved successfully'

    expect(find_field('Enable the Performance Bar')).to be_checked
    expect(find_field('Allowed group').value).to eq group.path

    uncheck 'Enable the Performance Bar'

    click_on 'Save'

    expect(page).to have_content 'Application settings saved successfully'

    expect(find_field('Enable the Performance Bar')).not_to be_checked
    expect(find_field('Allowed group').value).to be_nil
  end

121
122
123
124
125
126
127
128
129
130
  def check_all_events
    page.check('Active')
    page.check('Push')
    page.check('Tag push')
    page.check('Note')
    page.check('Issue')
    page.check('Merge request')
    page.check('Pipeline')
  end
end