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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2019-03-14 17:15:44 +0300
committerLin Jen-Shin <godfat@godfat.org>2019-03-19 08:01:37 +0300
commit7ce990b16181d05f57df4e89300c5db65b129747 (patch)
treef39d6ba813d83b355003a34acb16ab7467a4533a /spec/lib
parent7067806634a50df11a089fecd3c38200e248d499 (diff)
Move some application setting examples to be shared
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/fake_application_settings_spec.rb82
1 files changed, 15 insertions, 67 deletions
diff --git a/spec/lib/gitlab/fake_application_settings_spec.rb b/spec/lib/gitlab/fake_application_settings_spec.rb
index 0f864c4e124..c81cb83d9f4 100644
--- a/spec/lib/gitlab/fake_application_settings_spec.rb
+++ b/spec/lib/gitlab/fake_application_settings_spec.rb
@@ -1,85 +1,33 @@
require 'spec_helper'
describe Gitlab::FakeApplicationSettings do
- let(:defaults) { { password_authentication_enabled_for_web: false, foobar: 'asdf', signup_enabled: true, 'test?' => 123 } }
+ let(:defaults) do
+ described_class.defaults.merge(
+ foobar: 'asdf',
+ 'test?' => 123
+ )
+ end
- subject { described_class.new(defaults) }
+ let(:setting) { 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')
+ 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' 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
+ 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' do
- expect(subject.foobar?).to be_nil
+ expect(setting.foobar?).to be_nil
end
it 'does not override an existing predicate method' do
- expect(subject.test?).to eq(123)
+ expect(setting.test?).to eq(123)
end
- describe '#commit_email_hostname' do
- context 'when the value is provided' do
- let(:defaults) { { commit_email_hostname: 'localhost' } }
-
- it 'returns the provided value' do
- expect(subject.commit_email_hostname).to eq('localhost')
- end
- end
-
- context 'when the value is not provided' do
- it 'returns the default from the class' do
- expect(subject.commit_email_hostname)
- .to eq(described_class.default_commit_email_hostname)
- end
- end
- end
-
- describe '#usage_ping_enabled' do
- context 'when usage ping can be configured' do
- before do
- allow(Settings.gitlab)
- .to receive(:usage_ping_enabled).and_return(true)
- end
-
- it 'returns the value provided' do
- subject.usage_ping_enabled = true
-
- expect(subject.usage_ping_enabled).to eq(true)
-
- subject.usage_ping_enabled = false
-
- expect(subject.usage_ping_enabled).to eq(false)
- end
- end
-
- context 'when usage ping cannot be configured' do
- before do
- allow(Settings.gitlab)
- .to receive(:usage_ping_enabled).and_return(false)
- end
-
- it 'always returns false' do
- subject.usage_ping_enabled = true
-
- expect(subject.usage_ping_enabled).to eq(false)
-
- subject.usage_ping_enabled = false
-
- expect(subject.usage_ping_enabled).to eq(false)
- end
- end
- end
+ it_behaves_like 'application settings examples'
end