summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/fake_application_settings_spec.rb
blob: af12e13d36d90e95575c1edf20399678aecc673b (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
require 'spec_helper'

describe Gitlab::FakeApplicationSettings do
  let(:defaults) { { password_authentication_enabled_for_web: false, foobar: 'asdf', signup_enabled: true, 'test?' => 123 } }

  subject { described_class.new(defaults) }

  it 'wraps OpenStruct variables properly' do
    expect(subject.password_authentication_enabled_for_web).to be_falsey
    expect(subject.signup_enabled).to be_truthy
    expect(subject.foobar).to eq('asdf')
  end

  it 'defines predicate methods' do
    expect(subject.password_authentication_enabled_for_web?).to be_falsey
    expect(subject.signup_enabled?).to be_truthy
  end

  it 'predicate method changes when value is updated' do
    subject.password_authentication_enabled_for_web = true

    expect(subject.password_authentication_enabled_for_web?).to be_truthy
  end

  it 'does not define a predicate method' do
    expect(subject.foobar?).to be_nil
  end

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