1
0
Fork 0
forked from gitea/nas

Change registrations to be disabled by default for new servers (#29353)

This commit is contained in:
Claire 2024-02-22 18:15:59 +01:00 committed by GitHub
parent 4fd22acb4a
commit 328a9b8157
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 28 additions and 17 deletions

View file

@ -142,22 +142,12 @@ RSpec.describe Setting do
context 'when records includes nothing' do
let(:records) { [] }
context 'when default_value is not a Hash' do
it 'includes Setting with value of default_value' do
setting = described_class.all_as_records[key]
it 'includes Setting with value of default_value' do
setting = described_class.all_as_records[key]
expect(setting).to be_a described_class
expect(setting).to have_attributes(var: key)
expect(setting).to have_attributes(value: 'default_value')
end
end
context 'when default_value is a Hash' do
let(:default_value) { { 'foo' => 'fuga' } }
it 'returns {}' do
expect(described_class.all_as_records).to eq({})
end
expect(setting).to be_a described_class
expect(setting).to have_attributes(var: key)
expect(setting).to have_attributes(value: default_value)
end
end
end

View file

@ -152,6 +152,13 @@ RSpec.configure do |config|
self.use_transactional_tests = false
DatabaseCleaner.cleaning do
# NOTE: we switched registrations mode to closed by default, but the specs
# very heavily rely on having it enabled by default, as it relies on users
# being approved by default except in select cases where explicitly testing
# other registration modes
# Also needs to be set per-example here because of the database cleaner.
Setting.registrations_mode = 'open'
example.run
end

View file

@ -31,6 +31,12 @@ RSpec.configure do |config|
config.before :suite do
Rails.application.load_seed
Chewy.strategy(:bypass)
# NOTE: we switched registrations mode to closed by default, but the specs
# very heavily rely on having it enabled by default, as it relies on users
# being approved by default except in select cases where explicitly testing
# other registration modes
Setting.registrations_mode = 'open'
end
config.after :suite do