Fix issue with to_json on data proxies. For #2228

This commit is contained in:
Thomas Reynolds 2019-02-26 09:36:03 -08:00
parent 552c486b91
commit c99b616cf8
4 changed files with 25 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.vscode
.byebug_history
npm-debug.log
manifest.yaml

View File

@ -577,3 +577,23 @@ Feature: Incremental builds
| build/part-two.html |
And the file "build/part-one.html" should contain "Part = 4"
And the file "build/part-two.html" should contain "Part = 6"
Scenario: Wrapped collection methods, like `select`, should effect downstream methods.
Given an empty app
When a file named "config.rb" with:
"""
"""
When a file named "data/roles.yml" with:
"""
- title: "Job"
salary: 1111
"""
When a file named "source/roles/data.json.erb" with:
"""
{
"roles": <%= data.roles.select(&:salary).to_json %>
}
"""
Then build the app tracking dependencies
Then there are "1" files which are created
# with depth "1"

View File

@ -58,9 +58,9 @@ module Middleman
@data.to_s
end
def to_json
def to_json(*args)
log_access(:__full_access__)
@data.to_a.to_json
@data.to_a.to_json(*args)
end
private

View File

@ -27,9 +27,9 @@ module Middleman
@data.to_s
end
def to_json
def to_json(*args)
log_access(:__full_access__)
@data.to_h.to_json
@data.to_h.to_json(*args)
end
end
end