mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
parent
4857be1638
commit
1e6afa4020
2 changed files with 11 additions and 1 deletions
|
@ -7,7 +7,9 @@ module ActiveRecord
|
|||
:enum
|
||||
end
|
||||
|
||||
def cast(value)
|
||||
private
|
||||
|
||||
def cast_value(value)
|
||||
value.to_s
|
||||
end
|
||||
end
|
||||
|
|
|
@ -80,4 +80,12 @@ class PostgresqlEnumTest < ActiveRecord::TestCase
|
|||
|
||||
assert_equal "happy", enum.current_mood
|
||||
end
|
||||
|
||||
def test_assigning_enum_to_nil
|
||||
model = PostgresqlEnum.new(current_mood: nil)
|
||||
|
||||
assert_nil model.current_mood
|
||||
assert model.save
|
||||
assert_nil model.reload.current_mood
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue