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

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
  scenario 'Change application settings' do
33
    uncheck 'Gravatar enabled'
34
    fill_in 'Home page URL', with: 'https://about.gitlab.com/'
35
    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
    click_button 'Save'

Robert Speicher's avatar
Robert Speicher committed
41 42
    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
Robert Speicher's avatar
Robert Speicher committed
47
    expect(page).to have_content "Application settings saved successfully"
48
  end
49

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

59 60 61
    check_all_events
    click_on 'Save'

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

Kamil Trzcinski's avatar
Kamil Trzcinski committed
64
    click_link 'Slack notifications'
65

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

74 75 76 77 78 79 80 81
  context 'sign-in restrictions', :js do
    it 'de-activates oauth sign-in source' do
      find('.btn', text: 'GitLab.com').click
      
      expect(find('.btn', text: 'GitLab.com')).not_to have_css('.active')
    end
  end

82 83 84 85 86 87 88 89 90
  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
91
end