summaryrefslogtreecommitdiff
path: root/spec/views/admin/application_settings/_repository_check.html.haml_spec.rb
blob: 011f05eac21e994821ca1370f6e2e79f569fee78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'admin/application_settings/_repository_check.html.haml', feature_category: :source_code_management do
  let_it_be(:user) { create(:admin) }
  let_it_be(:application_setting) { build(:application_setting) }

  before do
    assign(:application_setting, application_setting)
    allow(view).to receive(:current_user).and_return(user)
  end

  describe 'repository checks' do
    it 'has the setting subsection' do
      render

      expect(rendered).to have_content('Repository checks')
    end

    it 'renders the correct setting subsection content' do
      render

      expect(rendered).to have_field('Enable repository checks')
      expect(rendered).to have_link(
        'Clear all repository checks',
        href: clear_repository_check_states_admin_application_settings_path
      )
    end
  end

  describe 'housekeeping' do
    it 'has the setting subsection' do
      render

      expect(rendered).to have_content('Housekeeping')
    end

    it 'renders the correct setting subsection content' do
      render

      expect(rendered).to have_field('Enable automatic repository housekeeping')
      expect(rendered).to have_field('Optimize repository period')
    end
  end

  describe 'inactive project deletion' do
    let_it_be(:application_setting) do
      build(:application_setting,
            delete_inactive_projects: true,
            inactive_projects_delete_after_months: 2,
            inactive_projects_min_size_mb: 250,
            inactive_projects_send_warning_email_after_months: 1
           )
    end

    it 'has the setting subsection' do
      render

      expect(rendered).to have_content('Inactive project deletion')
    end

    it 'renders the correct setting subsection content' do
      render

      expect(rendered).to have_selector('.js-inactive-project-deletion-form')
      expect(rendered).to have_selector('[data-delete-inactive-projects="true"]')
      expect(rendered).to have_selector('[data-inactive-projects-delete-after-months="2"]')
      expect(rendered).to have_selector('[data-inactive-projects-min-size-mb="250"]')
      expect(rendered).to have_selector('[data-inactive-projects-send-warning-email-after-months="1"]')
    end
  end
end