Skip to content

Commit d2161bd

Browse files
authored
Merge pull request #550 from casperisfine/collection-caching-test
Add a test for `render collection:, cached: true`
2 parents 08a4154 + 5a483e6 commit d2161bd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/jbuilder_template_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ class JbuilderTemplateTest < ActiveSupport::TestCase
7373
assert_equal "Pavel", result[5]["author"]["first_name"]
7474
end
7575

76+
test "partial collection by name with caching" do
77+
result = render('json.partial! "post", collection: @posts, cached: true, as: :post', posts: POSTS)
78+
assert_equal 10, result.count
79+
assert_equal "Post #5", result[4]["body"]
80+
assert_equal "Heinemeier Hansson", result[2]["author"]["last_name"]
81+
assert_equal "Pavel", result[5]["author"]["first_name"]
82+
end
83+
7684
test "partial collection by name with string local" do
7785
result = render('json.partial! "post", collection: @posts, as: "post"', posts: POSTS)
7886
assert_equal 10, result.count

0 commit comments

Comments
 (0)