Skip to content

Commit 53e6b9e

Browse files
committed
Make the test suite pass with Rails 7.1 and Ruby 3.3
Fixes a number of small issues.
1 parent 522de58 commit 53e6b9e

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
matrix:
1414
include:
1515
# Recent Rubies and Rails
16-
# - ruby-version: '3.1'
17-
# rails-version: '7.0'
16+
- ruby-version: '3.3'
17+
rails-version: '7.1'
1818
# - ruby-version: '3.0'
1919
# rails-version: '7.0'
2020
# - ruby-version: '2.7'

Gemfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ end
7070

7171
group :test do
7272
platforms(*(@windows_platforms + [:ruby])) do
73-
if version == 'master' || version >= '6'
74-
gem 'sqlite3', '~> 1.4'
75-
else
73+
if RUBY_VERSION < '2.5' || version < '6'
7674
gem 'sqlite3', '~> 1.3.13'
75+
else
76+
gem 'sqlite3'
7777
end
7878
end
7979
platforms :jruby do

lib/action_controller/serialization_test_case.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def process(*args)
2424
@serializers = Hash.new(0)
2525
super
2626
end
27+
ruby2_keywords :process if respond_to?(:ruby2_keywords, true)
2728

2829
# Asserts that the request was rendered with the appropriate serializers.
2930
#

test/integration/action_controller/serialization_test.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def render_using_implicit_serializer
1313

1414
def test_render_using_implicit_serializer
1515
get :render_using_implicit_serializer
16-
assert_equal 'application/json', @response.content_type
16+
assert_includes @response.content_type, 'application/json'
1717
assert_equal '{"profile":{"name":"Name 1","description":"Description 1"}}', @response.body
1818
end
1919
end
@@ -35,7 +35,7 @@ def current_user
3535

3636
def test_render_using_implicit_serializer_and_scope
3737
get :render_using_implicit_serializer_and_scope
38-
assert_equal 'application/json', @response.content_type
38+
assert_includes @response.content_type, 'application/json'
3939
assert_equal '{"profile":{"name":"Name 1","description":"Description 1 - current_user"}}', @response.body
4040
end
4141
end
@@ -65,7 +65,7 @@ def current_admin
6565

6666
def test_render_using_scope_set_in_default_serializer_options
6767
get :render_using_scope_set_in_default_serializer_options
68-
assert_equal 'application/json', @response.content_type
68+
assert_includes @response.content_type, 'application/json'
6969
assert_equal '{"profile":{"name":"Name 1","description":"Description 1 - current_admin"}}', @response.body
7070
end
7171
end
@@ -91,7 +91,7 @@ def current_admin
9191

9292
def test_render_using_implicit_serializer_and_explicit_scope
9393
get :render_using_implicit_serializer_and_explicit_scope
94-
assert_equal 'application/json', @response.content_type
94+
assert_includes @response.content_type, 'application/json'
9595
assert_equal '{"profile":{"name":"Name 1","description":"Description 1 - current_admin"}}', @response.body
9696
end
9797
end
@@ -117,7 +117,7 @@ def serialization_scope
117117

118118
def test_render_overriding_serialization_scope
119119
get :render_overriding_serialization_scope
120-
assert_equal 'application/json', @response.content_type
120+
assert_includes @response.content_type, 'application/json'
121121
assert_equal '{"profile":{"name":"Name 1","description":"Description 1 - current_admin"}}', @response.body
122122
end
123123
end
@@ -141,7 +141,7 @@ def current_user
141141

142142
def test_render_calling_serialization_scope
143143
get :render_calling_serialization_scope
144-
assert_equal 'application/json', @response.content_type
144+
assert_includes @response.content_type, 'application/json'
145145
assert_equal '{"profile":{"name":"Name 1","description":"Description 1 - current_user"}}', @response.body
146146
end
147147
end
@@ -157,7 +157,7 @@ def render_using_json_dump
157157

158158
def test_render_using_json_dump
159159
get :render_using_json_dump
160-
assert_equal 'application/json', @response.content_type
160+
assert_includes @response.content_type, 'application/json'
161161
assert_equal '{"hello":"world"}', @response.body
162162
end
163163
end
@@ -173,7 +173,7 @@ def render_using_rails_behavior
173173

174174
def test_render_using_rails_behavior
175175
get :render_using_rails_behavior
176-
assert_equal 'application/json', @response.content_type
176+
assert_includes @response.content_type, 'application/json'
177177
assert_equal '[{"attributes":{"name":"Name 1","description":"Description 1","comments":"Comments 1"}}]', @response.body
178178
end
179179
end
@@ -189,7 +189,7 @@ def render_array
189189

190190
def test_render_array
191191
get :render_array
192-
assert_equal 'application/json', @response.content_type
192+
assert_includes @response.content_type, 'application/json'
193193
assert_equal '{"my":[{"name":"Name 1","description":"Description 1"}]}', @response.body
194194
end
195195
end
@@ -205,7 +205,7 @@ def render_array
205205

206206
def test_render_array
207207
get :render_array
208-
assert_equal 'application/json', @response.content_type
208+
assert_includes @response.content_type, 'application/json'
209209
assert_equal '{"webLog":[{"name":"Name 1","displayName":"Display Name 1"},{"name":"Name 2","displayName":"Display Name 2"}]}', @response.body
210210
end
211211
end
@@ -223,7 +223,7 @@ def render_without_root
223223

224224
def test_render_without_root
225225
get :render_without_root
226-
assert_equal 'application/json', @response.content_type
226+
assert_includes @response.content_type, 'application/json'
227227
assert_equal '{"name":"Name 1","displayName":"Display Name 1"}', @response.body
228228
end
229229
end
@@ -242,7 +242,7 @@ def render_array_without_root
242242

243243
def test_render_array_without_root
244244
get :render_array_without_root
245-
assert_equal 'application/json', @response.content_type
245+
assert_includes @response.content_type, 'application/json'
246246
assert_equal '[{"name":"Name 1","displayName":"Display Name 1"},{"name":"Name 2","displayName":"Display Name 2"}]', @response.body
247247
end
248248
end
@@ -278,7 +278,7 @@ def test_render_array_embeding_in_root
278278
@association.embed_in_root = true
279279

280280
get :render_array_embeding_in_root
281-
assert_equal 'application/json', @response.content_type
281+
assert_includes @response.content_type, 'application/json'
282282

283283
assert_equal("{\"my\":[{\"name\":\"Name 1\",\"email\":\"[email protected]\",\"profile_id\":#{@controller.user.profile.object_id}}],\"profiles\":[{\"name\":\"N1\",\"description\":\"D1\"}]}", @response.body)
284284
end

0 commit comments

Comments
 (0)