[Rails5] Add FALSE_VALUES constant to Service#boolean_accessor

In Rails 5.0 the `ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES`
constant has been removed [1] and the remaining `FALSE_VALUES` constant
has been moved to `ActiveModel::Type::Boolean` [2]

[1]: a502703c3d
[2]: 9cc8c6f373
This commit is contained in:
blackst0ne 2018-04-08 09:48:38 +11:00
parent aade8b3652
commit 432e57fccf
1 changed files with 5 additions and 1 deletions

View File

@ -206,7 +206,11 @@ class Service < ActiveRecord::Base
args.each do |arg|
class_eval %{
def #{arg}?
ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(#{arg})
if Gitlab.rails5?
!ActiveModel::Type::Boolean::FALSE_VALUES.include?(#{arg})
else
ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(#{arg})
end
end
}
end