575dced5d7
master was failing because `ApplicationSetting.create_from_defaults` attempted to write to a column that did not exist in the database. This occurred in a `rake db:migrate` task, which was unable to perform the migration that would have added the missing column in the first place. In 9.3 RC2, we also had a bug where password sign-ins were disabled because there were many pending migrations. The problem occurred because `fake_application_settings` was being returned with an OpenStruct that did not include the predicate method `signup_enabled?`. As a result, the value would erroneously return `nil` instead of `true`. This commit uses the values of the defaults to mimic this behavior. This commit also refactors some of the logic to be clearer.
32 lines
887 B
Ruby
32 lines
887 B
Ruby
require 'spec_helper'
|
|
|
|
describe Gitlab::FakeApplicationSettings do
|
|
let(:defaults) { { signin_enabled: false, foobar: 'asdf', signup_enabled: true, 'test?' => 123 } }
|
|
|
|
subject { described_class.new(defaults) }
|
|
|
|
it 'wraps OpenStruct variables properly' do
|
|
expect(subject.signin_enabled).to be_falsey
|
|
expect(subject.signup_enabled).to be_truthy
|
|
expect(subject.foobar).to eq('asdf')
|
|
end
|
|
|
|
it 'defines predicate methods' do
|
|
expect(subject.signin_enabled?).to be_falsey
|
|
expect(subject.signup_enabled?).to be_truthy
|
|
end
|
|
|
|
it 'predicate method changes when value is updated' do
|
|
subject.signin_enabled = true
|
|
|
|
expect(subject.signin_enabled?).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
|