File tree Expand file tree Collapse file tree 3 files changed +23
-7
lines changed
lib/active_model/serializer Expand file tree Collapse file tree 3 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ def test_model_name
106106 private
107107
108108 def resource
109- @resource
109+ @resource or fail "'@resource' must be set as the linted object"
110110 end
111111
112112 def assert_instance_of ( result , name )
Original file line number Diff line number Diff line change @@ -13,12 +13,8 @@ def cache_key
1313 "#{ self . class . name . downcase } /#{ self . id } -#{ self . updated_at . strftime ( "%Y%m%d%H%M%S%9N" ) } "
1414 end
1515
16- def cache_key_with_digest
17- "#{ cache_key } /#{ FILE_DIGEST } "
18- end
19-
20- def updated_at
21- @attributes [ :updated_at ] ||= DateTime . now . to_time
16+ def serializable_hash ( options = nil )
17+ @attributes
2218 end
2319
2420 def read_attribute_for_serialization ( name )
3329 @attributes [ :id ] || @attributes [ 'id' ] || object_id
3430 end
3531
32+ ### Helper methods, not required to be serializable
33+ #
34+ # Convenience for adding @attributes readers and writers
3635 def method_missing ( meth , *args )
3736 if meth . to_s =~ /^(.*)=$/
3837 @attributes [ $1. to_sym ] = args [ 0 ]
@@ -42,6 +41,14 @@ def method_missing(meth, *args)
4241 super
4342 end
4443 end
44+
45+ def cache_key_with_digest
46+ "#{ cache_key } /#{ FILE_DIGEST } "
47+ end
48+
49+ def updated_at
50+ @attributes [ :updated_at ] ||= DateTime . now . to_time
51+ end
4552end
4653
4754class Profile < Model
Original file line number Diff line number Diff line change 1+ require 'test_helper'
2+
3+ class PoroTest < Minitest ::Test
4+ include ActiveModel ::Serializer ::Lint ::Tests
5+
6+ def setup
7+ @resource = Model . new
8+ end
9+ end
You can’t perform that action at this time.
0 commit comments