File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,10 @@ def deserialize(value)
8686 end
8787
8888 alias type_cast_from_database deserialize
89+
90+ def as_json ( options = nil )
91+ { attr : @attr . name , subtype : @subtype } . as_json ( options )
92+ end
8993 end
9094 end
9195end
Original file line number Diff line number Diff line change @@ -507,11 +507,14 @@ class InterestsRequiredUser < User
507507 end
508508
509509 it 'supports AR types serialization' do
510- User . delete_all
511-
512510 type = User . type_for_attribute ( 'status' )
513511 type . must_be_instance_of Enumerize ::ActiveRecordSupport ::Type
514512 serialized = type . serialize ( 'blocked' )
515513 serialized . must_equal 2
516514 end
515+
516+ it 'has AR type itself JSON serializable' do
517+ type = User . type_for_attribute ( 'status' )
518+ type . as_json [ 'attr' ] . must_equal 'status'
519+ end
517520end
You can’t perform that action at this time.
0 commit comments