Skip to content

Commit

Permalink
Merge pull request #550 from casperisfine/collection-caching-test
Browse files Browse the repository at this point in the history
Add a test for `render collection:, cached: true`
  • Loading branch information
rafaelfranca authored Aug 22, 2023
2 parents 08a4154 + 5a483e6 commit d2161bd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/jbuilder_template_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ class JbuilderTemplateTest < ActiveSupport::TestCase
assert_equal "Pavel", result[5]["author"]["first_name"]
end

test "partial collection by name with caching" do
result = render('json.partial! "post", collection: @posts, cached: true, as: :post', posts: POSTS)
assert_equal 10, result.count
assert_equal "Post #5", result[4]["body"]
assert_equal "Heinemeier Hansson", result[2]["author"]["last_name"]
assert_equal "Pavel", result[5]["author"]["first_name"]
end

test "partial collection by name with string local" do
result = render('json.partial! "post", collection: @posts, as: "post"', posts: POSTS)
assert_equal 10, result.count
Expand Down

0 comments on commit d2161bd

Please sign in to comment.