Welcome to mirror list, hosted at ThFree Co, Russian Federation.

fake_application_settings_spec.rb « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b300498e898e8ed03a73b2609aa5b6ec12446f4c (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::FakeApplicationSettings do
  let(:defaults) do
    described_class.defaults.merge(
      foobar: 'asdf',
      'test?'.to_sym => 123,
      # these two settings have no default in ApplicationSettingImplementation,
      # so we need to set one here
      domain_denylist: [],
      archive_builds_in_seconds: nil
    )
  end

  let(:setting) { described_class.new(defaults) }

  it 'defines methods for default attributes' do
    expect(setting.password_authentication_enabled_for_web).to be_truthy
    expect(setting.signup_enabled).to be_truthy
    expect(setting.foobar).to eq('asdf')
  end

  it 'defines predicate methods for boolean properties' do
    expect(setting.password_authentication_enabled_for_web?).to be_truthy
    expect(setting.signup_enabled?).to be_truthy
  end

  it 'does not define a predicate method for non-boolean properties' do
    expect(setting.foobar?).to be_nil
  end

  it 'returns nil for undefined attributes' do
    expect(setting.does_not_exist).to be_nil
  end

  it 'does not override an existing predicate method' do
    expect(setting.test?).to eq(123)
  end

  it_behaves_like 'application settings examples'
end