File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
test/integration/action_controller Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 7
7
- ruby-head
8
8
- jruby-19mode
9
9
- rbx-2
10
+ - ruby-head
10
11
11
12
sudo : false
12
13
14
+ install :
15
+ - bundle install --retry=3
16
+
13
17
env :
14
18
- " RAILS_VERSION=3.2.17"
15
19
- " RAILS_VERSION=4.0.3"
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ def format_keys(format)
56
56
attr_reader :key_format
57
57
58
58
def serializer_for ( resource , options = { } )
59
- if resource . respond_to? ( :each )
59
+ if resource . respond_to? ( :each ) && ! resource . is_a? ( Hash )
60
60
if Object . constants . include? ( :ArraySerializer )
61
61
::ArraySerializer
62
62
else
Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ def render_comment
19
19
def render_comments
20
20
render json : [ Comment . new ( content : 'Comment 1' ) ]
21
21
end
22
+
23
+ def render_hash
24
+ render json : { message : 'not found' } , status : 404
25
+ end
22
26
end
23
27
24
28
tests TestNamespace ::MyController
@@ -42,6 +46,11 @@ def test_array_fallback_to_a_version_without_namespace
42
46
get :render_comments
43
47
assert_serializer CommentSerializer
44
48
end
49
+
50
+ def test_render_hash_regression
51
+ get :render_hash
52
+ assert_equal JSON . parse ( response . body ) , { 'message' => 'not found' }
53
+ end
45
54
end
46
55
47
56
class OptionNamespacedSerializationTest < ActionController ::TestCase
@@ -93,4 +102,4 @@ def test_array_fallback_to_a_version_without_namespace
93
102
end
94
103
95
104
end
96
- end
105
+ end
You can’t perform that action at this time.
0 commit comments