-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Locals need to be shallow cloned.
Resolves #20. `prop_template` prebuilds an array of options before handling it off to handle_collection to build. I recall this being somewhat related to faster collection rendering. Unfortunately, the trade off is that we have to be cognizant of how we mutate deeply nested options as those can be the same object. In this case, I missed a required clone on locals.
- Loading branch information
Showing
3 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,6 +299,22 @@ | |
]) | ||
end | ||
|
||
it "renders an array with cloned :locals" do | ||
json = render(<<~PROPS) | ||
emails = [ | ||
{value: '[email protected]'}, | ||
{value: '[email protected]'}, | ||
] | ||
json.array! emails, partial: ['simple_as', locals: {}] do | ||
end | ||
PROPS | ||
|
||
expect(json).to eql_json([ | ||
{foo: "[email protected]"}, | ||
{foo: "[email protected]"} | ||
]) | ||
end | ||
|
||
it "renders an an empty array" do | ||
json = render(<<~PROPS) | ||
json.array! [], {partial: 'simple'} do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.foo simple_as[:value] |