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
106
106
private
107
107
108
108
def resource
109
- @resource
109
+ @resource or fail "'@resource' must be set as the linted object"
110
110
end
111
111
112
112
def assert_instance_of ( result , name )
Original file line number Diff line number Diff line change @@ -13,12 +13,8 @@ def cache_key
13
13
"#{ self . class . name . downcase } /#{ self . id } -#{ self . updated_at . strftime ( "%Y%m%d%H%M%S%9N" ) } "
14
14
end
15
15
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
22
18
end
23
19
24
20
def read_attribute_for_serialization ( name )
33
29
@attributes [ :id ] || @attributes [ 'id' ] || object_id
34
30
end
35
31
32
+ ### Helper methods, not required to be serializable
33
+ #
34
+ # Convenience for adding @attributes readers and writers
36
35
def method_missing ( meth , *args )
37
36
if meth . to_s =~ /^(.*)=$/
38
37
@attributes [ $1. to_sym ] = args [ 0 ]
@@ -42,6 +41,14 @@ def method_missing(meth, *args)
42
41
super
43
42
end
44
43
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
45
52
end
46
53
47
54
class 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