debian-mirror-gitlab/spec/lib/gitlab/fake_application_settings_spec.rb

44 lines
1.2 KiB
Ruby
Raw Normal View History

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