mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 17:28:18 +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
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue