mirror of
https://github.com/internetee/registry.git
synced 2025-08-15 14:03:49 +02:00
Test boolean setting returns false for nil value
This commit is contained in:
parent
2330e8eab1
commit
75181f5bea
3 changed files with 7 additions and 9 deletions
|
@ -18,7 +18,7 @@ class SettingEntry < ApplicationRecord
|
||||||
|
|
||||||
def retrieve
|
def retrieve
|
||||||
method = VALUE_FORMATS[format]
|
method = VALUE_FORMATS[format]
|
||||||
return false if format == 'boolean' && value.blank?
|
return false if self.format == 'boolean' && value.blank?
|
||||||
return if value.blank?
|
return if value.blank?
|
||||||
|
|
||||||
send(method)
|
send(method)
|
||||||
|
@ -49,9 +49,10 @@ class SettingEntry < ApplicationRecord
|
||||||
|
|
||||||
# Hooks
|
# Hooks
|
||||||
def replace_boolean_nil_with_false
|
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
|
end
|
||||||
|
|
||||||
def validate_code_is_not_using_reserved_name
|
def validate_code_is_not_using_reserved_name
|
||||||
|
|
|
@ -103,6 +103,9 @@ class SettingEntryTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
Setting.boolean_format = 'false'
|
Setting.boolean_format = 'false'
|
||||||
assert_equal false, Setting.boolean_format
|
assert_equal false, Setting.boolean_format
|
||||||
|
|
||||||
|
Setting.boolean_format = nil
|
||||||
|
assert_equal false, Setting.boolean_format
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parses_hash_format
|
def test_parses_hash_format
|
||||||
|
|
|
@ -44,7 +44,6 @@ class ActiveSupport::TestCase
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
travel_back
|
travel_back
|
||||||
Setting.address_processing = false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,14 +57,9 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest
|
||||||
WebMock.reset!
|
WebMock.reset!
|
||||||
Capybara.reset_sessions!
|
Capybara.reset_sessions!
|
||||||
Capybara.use_default_driver
|
Capybara.use_default_driver
|
||||||
Setting.address_processing = false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class EppTestCase < ActionDispatch::IntegrationTest
|
class EppTestCase < ActionDispatch::IntegrationTest
|
||||||
include Assertions::EppAssertions
|
include Assertions::EppAssertions
|
||||||
|
|
||||||
teardown do
|
|
||||||
Setting.address_processing = false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue