Skip to content

Commit 1df2b3b

Browse files
DavidMikeSimonlgebhardt
authored andcommitted
Skip preloading of polymorphic relations, better handling of serialization with partially preloaded relations, resolves #889
(cherry picked from commit d9d9d3f)
1 parent a5b06b6 commit 1df2b3b

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

test/controllers/controller_test.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,36 @@ def test_documents_index_with_polymorphic_include_one_level
19721972
end
19731973
end
19741974

1975+
class PicturesControllerTest < ActionController::TestCase
1976+
def test_pictures_index
1977+
assert_cacheable_get :index
1978+
assert_response :success
1979+
assert_equal 3, json_response['data'].size
1980+
end
1981+
1982+
def test_pictures_index_with_polymorphic_include_one_level
1983+
assert_cacheable_get :index, params: {include: 'imageable'}
1984+
assert_response :success
1985+
assert_equal 3, json_response['data'].size
1986+
assert_equal 2, json_response['included'].size
1987+
end
1988+
end
1989+
1990+
class DocumentsControllerTest < ActionController::TestCase
1991+
def test_documents_index
1992+
assert_cacheable_get :index
1993+
assert_response :success
1994+
assert_equal 1, json_response['data'].size
1995+
end
1996+
1997+
def test_documents_index_with_polymorphic_include_one_level
1998+
assert_cacheable_get :index, params: {include: 'pictures'}
1999+
assert_response :success
2000+
assert_equal 1, json_response['data'].size
2001+
assert_equal 1, json_response['included'].size
2002+
end
2003+
end
2004+
19752005
class ExpenseEntriesControllerTest < ActionController::TestCase
19762006
def setup
19772007
JSONAPI.configuration.json_key_format = :camelized_key

0 commit comments

Comments
 (0)