diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-05-29 14:46:42 +0200 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-05-29 14:46:42 +0200 |
commit | 884fbf1d058ac00bc5c107f327475fa6eeda1f9f (patch) | |
tree | 57005825ac8641943fc0d5aa0b27f3c70b6f49f8 | |
parent | c5adf04cd69035a7a1737df8c2303bc228ea4089 (diff) | |
download | gitlab-ce-884fbf1d058ac00bc5c107f327475fa6eeda1f9f.tar.gz |
Fix boolean casting for nil value
`nil` value is not included in
`ActiveModel::Type::Boolean::FALSE_VALUES` which caused that in Rails 5
the boolean_accessor converted `nil` to `true` instead of `false`.
-rw-r--r-- | app/models/service.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/service.rb b/app/models/service.rb index 831c2ea1141..1d259bcfec7 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -206,10 +206,11 @@ class Service < ActiveRecord::Base args.each do |arg| class_eval %{ def #{arg}? + # '!!' is used because nil or empty string is converted to nil if Gitlab.rails5? - !ActiveModel::Type::Boolean::FALSE_VALUES.include?(#{arg}) + !!ActiveRecord::Type::Boolean.new.cast(#{arg}) else - ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(#{arg}) + !!ActiveRecord::Type::Boolean.new.type_cast_from_database(#{arg}) end end } |