2019-11-07 22:06:48 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-17 10:35:30 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::FakeApplicationSettings do
|
2019-03-14 10:15:44 -04:00
|
|
|
let(:defaults) do
|
|
|
|
described_class.defaults.merge(
|
|
|
|
foobar: 'asdf',
|
2021-08-11 05:10:00 -04:00
|
|
|
'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
|
2019-03-14 10:15:44 -04:00
|
|
|
)
|
|
|
|
end
|
2017-06-17 10:35:30 -04:00
|
|
|
|
2019-03-14 10:15:44 -04:00
|
|
|
let(:setting) { described_class.new(defaults) }
|
2017-06-17 10:35:30 -04:00
|
|
|
|
2021-08-11 05:10:00 -04:00
|
|
|
it 'defines methods for default attributes' do
|
2019-03-14 10:15:44 -04:00
|
|
|
expect(setting.password_authentication_enabled_for_web).to be_truthy
|
|
|
|
expect(setting.signup_enabled).to be_truthy
|
|
|
|
expect(setting.foobar).to eq('asdf')
|
2017-06-17 10:35:30 -04:00
|
|
|
end
|
|
|
|
|
2021-08-11 05:10:00 -04:00
|
|
|
it 'defines predicate methods for boolean properties' do
|
2019-03-14 10:15:44 -04:00
|
|
|
expect(setting.password_authentication_enabled_for_web?).to be_truthy
|
|
|
|
expect(setting.signup_enabled?).to be_truthy
|
2017-06-17 10:35:30 -04:00
|
|
|
end
|
|
|
|
|
2021-08-11 05:10:00 -04:00
|
|
|
it 'does not define a predicate method for non-boolean properties' do
|
2019-03-14 10:15:44 -04:00
|
|
|
expect(setting.foobar?).to be_nil
|
2017-06-17 10:35:30 -04:00
|
|
|
end
|
|
|
|
|
2021-08-11 05:10:00 -04:00
|
|
|
it 'returns nil for undefined attributes' do
|
|
|
|
expect(setting.does_not_exist).to be_nil
|
|
|
|
end
|
|
|
|
|
2017-06-17 10:35:30 -04:00
|
|
|
it 'does not override an existing predicate method' do
|
2019-03-14 10:15:44 -04:00
|
|
|
expect(setting.test?).to eq(123)
|
2017-06-17 10:35:30 -04:00
|
|
|
end
|
2019-03-11 09:29:11 -04:00
|
|
|
|
2019-03-14 10:15:44 -04:00
|
|
|
it_behaves_like 'application settings examples'
|
2017-06-17 10:35:30 -04:00
|
|
|
end
|