mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Remove controller :assigns warnings/shim
This commit is contained in:
parent
913f396bb1
commit
caf4910b6e
@ -32,7 +32,7 @@ module ActionController
|
|||||||
|
|
||||||
expected = {
|
expected = {
|
||||||
data: {
|
data: {
|
||||||
id: assigns(:profile).id.to_s,
|
id: @controller.instance_variable_get(:@profile).id.to_s,
|
||||||
type: 'profiles',
|
type: 'profiles',
|
||||||
attributes: {
|
attributes: {
|
||||||
name: 'Name 1',
|
name: 'Name 1',
|
||||||
|
|||||||
@ -103,9 +103,9 @@ module ActionController
|
|||||||
{
|
{
|
||||||
'title' => 'New Post',
|
'title' => 'New Post',
|
||||||
'body' => 'Body',
|
'body' => 'Body',
|
||||||
'id' => assigns(:post).id,
|
'id' => @controller.instance_variable_get(:@post).id,
|
||||||
'comments' => [{ 'id' => 1 }, { 'id' => 2 }],
|
'comments' => [{ 'id' => 1 }, { 'id' => 2 }],
|
||||||
'author' => { 'id' => assigns(:author).id }
|
'author' => { 'id' => @controller.instance_variable_get(:@author).id }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -163,7 +163,7 @@ module ActionController
|
|||||||
end
|
end
|
||||||
expected = {
|
expected = {
|
||||||
data: {
|
data: {
|
||||||
id: assigns(:profile).id.to_s,
|
id: @controller.instance_variable_get(:@profile).id.to_s,
|
||||||
type: 'profiles',
|
type: 'profiles',
|
||||||
attributes: {
|
attributes: {
|
||||||
name: 'Name 1',
|
name: 'Name 1',
|
||||||
@ -246,7 +246,7 @@ module ActionController
|
|||||||
expected = {
|
expected = {
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
id: assigns(:profiles).first.id.to_s,
|
id: @controller.instance_variable_get(:@profiles).first.id.to_s,
|
||||||
type: 'profiles',
|
type: 'profiles',
|
||||||
attributes: {
|
attributes: {
|
||||||
name: 'Name 1',
|
name: 'Name 1',
|
||||||
@ -269,7 +269,7 @@ module ActionController
|
|||||||
expected = {
|
expected = {
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
id: assigns(:profiles).first.id.to_s,
|
id: @controller.instance_variable_get(:@profiles).first.id.to_s,
|
||||||
type: 'profiles',
|
type: 'profiles',
|
||||||
attributes: {
|
attributes: {
|
||||||
name: 'Name 1',
|
name: 'Name 1',
|
||||||
|
|||||||
@ -22,15 +22,6 @@ ActionController::TestCase.class_eval do
|
|||||||
def setup
|
def setup
|
||||||
@routes = Routes
|
@routes = Routes
|
||||||
end
|
end
|
||||||
|
|
||||||
# For Rails5
|
|
||||||
# https://github.com/rails/rails/commit/ca83436d1b3b6cedd1eca2259f65661e69b01909#diff-b9bbf56e85d3fe1999f16317f2751e76L17
|
|
||||||
def assigns(key = nil)
|
|
||||||
warn "DEPRECATION: Calling 'assigns(#{key})' from #{caller[0]}"
|
|
||||||
assigns = {}.with_indifferent_access
|
|
||||||
@controller.view_assigns.each { |k, v| assigns.regular_writer(k, v) }
|
|
||||||
key.nil? ? assigns : assigns[key]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
# ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user