Test boolean setting returns false for nil value

This commit is contained in:
Karl Erik Õunapuu 2020-08-18 11:41:42 +03:00
parent 2330e8eab1
commit 75181f5bea
3 changed files with 7 additions and 9 deletions

View file

@ -18,7 +18,7 @@ class SettingEntry < ApplicationRecord
def retrieve
method = VALUE_FORMATS[format]
return false if format == 'boolean' && value.blank?
return false if self.format == 'boolean' && value.blank?
return if value.blank?
send(method)
@ -49,9 +49,10 @@ class SettingEntry < ApplicationRecord
# Hooks
def replace_boolean_nil_with_false
return unless format == 'boolean'
return unless self.format == 'boolean'
return if value == 'true'
self.value = value == 'true' ? 'true' : 'false'
self.value = 'false'
end
def validate_code_is_not_using_reserved_name

View file

@ -103,6 +103,9 @@ class SettingEntryTest < ActiveSupport::TestCase
Setting.boolean_format = 'false'
assert_equal false, Setting.boolean_format
Setting.boolean_format = nil
assert_equal false, Setting.boolean_format
end
def test_parses_hash_format

View file

@ -44,7 +44,6 @@ class ActiveSupport::TestCase
teardown do
travel_back
Setting.address_processing = false
end
end
@ -58,14 +57,9 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest
WebMock.reset!
Capybara.reset_sessions!
Capybara.use_default_driver
Setting.address_processing = false
end
end
class EppTestCase < ActionDispatch::IntegrationTest
include Assertions::EppAssertions
teardown do
Setting.address_processing = false
end
end