Skip to content

Commit

Permalink
CollectionRenderer doesn't worj with locals
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav (Stas) Katkov committed Sep 20, 2024
1 parent 7586fec commit 4143a00
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/pbbuilder_template_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ class PbbuilderTemplateTest < ActiveSupport::TestCase
end
end

test "should be possible to pass variable with CollectionRenderer" do
template = <<-PBBUILDER
racers = [Racer.new(1, "Johnny Test", [], nil, API::Asset.new(url: "https://google.com/test1.svg")), Racer.new(2, "Max Verstappen", [])]
pb.friends racers, partial: "team", as: :racer, locals: { team_name: "Red Bull Racing" }
PBBUILDER

result = render(template)

assert_equal 2, result.friends.count
result.friends.each do |member|
assert_equal "Red Bull Racing", member.team_name
end
end

test "collection partial with fragment caching enabled" do
template = <<-PBBUILDER
racers = [Racer.new(1, "Johnny Test", [], nil, API::Asset.new(url: "https://google.com/test1.svg")), Racer.new(2, "Max Verstappen", [])]
Expand Down

0 comments on commit 4143a00

Please sign in to comment.