Skip to content

Commit caf4910

Browse files
committed
Remove controller :assigns warnings/shim
1 parent 913f396 commit caf4910

File tree

4 files changed

+6
-15
lines changed

4 files changed

+6
-15
lines changed

test/action_controller/adapter_selector_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_render_using_adapter_override
3232

3333
expected = {
3434
data: {
35-
id: assigns(:profile).id.to_s,
35+
id: @controller.instance_variable_get(:@profile).id.to_s,
3636
type: 'profiles',
3737
attributes: {
3838
name: 'Name 1',

test/action_controller/explicit_serializer_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ def test_render_array_using_explicit_serializer_and_custom_serializers
103103
{
104104
'title' => 'New Post',
105105
'body' => 'Body',
106-
'id' => assigns(:post).id,
106+
'id' => @controller.instance_variable_get(:@post).id,
107107
'comments' => [{ 'id' => 1 }, { 'id' => 2 }],
108-
'author' => { 'id' => assigns(:author).id }
108+
'author' => { 'id' => @controller.instance_variable_get(:@author).id }
109109
}
110110
]
111111

test/action_controller/serialization_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_render_using_default_root
163163
end
164164
expected = {
165165
data: {
166-
id: assigns(:profile).id.to_s,
166+
id: @controller.instance_variable_get(:@profile).id.to_s,
167167
type: 'profiles',
168168
attributes: {
169169
name: 'Name 1',
@@ -246,7 +246,7 @@ def test_render_array_using_implicit_serializer_and_meta
246246
expected = {
247247
data: [
248248
{
249-
id: assigns(:profiles).first.id.to_s,
249+
id: @controller.instance_variable_get(:@profiles).first.id.to_s,
250250
type: 'profiles',
251251
attributes: {
252252
name: 'Name 1',
@@ -269,7 +269,7 @@ def test_render_array_using_implicit_serializer_and_links
269269
expected = {
270270
data: [
271271
{
272-
id: assigns(:profiles).first.id.to_s,
272+
id: @controller.instance_variable_get(:@profiles).first.id.to_s,
273273
type: 'profiles',
274274
attributes: {
275275
name: 'Name 1',

test/support/rails_app.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ module ActiveModelSerializers
2222
def setup
2323
@routes = Routes
2424
end
25-
26-
# For Rails5
27-
# https://github.com/rails/rails/commit/ca83436d1b3b6cedd1eca2259f65661e69b01909#diff-b9bbf56e85d3fe1999f16317f2751e76L17
28-
def assigns(key = nil)
29-
warn "DEPRECATION: Calling 'assigns(#{key})' from #{caller[0]}"
30-
assigns = {}.with_indifferent_access
31-
@controller.view_assigns.each { |k, v| assigns.regular_writer(k, v) }
32-
key.nil? ? assigns : assigns[key]
33-
end
3425
end
3526

3627
# ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]

0 commit comments

Comments
 (0)