mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Steps should try passing unknown methods to config context before failing. Fixes #1879
This commit is contained in:
parent
f2535f4fda
commit
a01656df39
4 changed files with 40 additions and 6 deletions
|
@ -1,6 +1,10 @@
|
|||
master
|
||||
===
|
||||
|
||||
# 4.1.8
|
||||
|
||||
* Let collection loops access ConfigContext for helpers. #1879
|
||||
|
||||
# 4.1.7
|
||||
|
||||
* Upgrade fastimage to 2.0
|
||||
|
|
|
@ -144,6 +144,33 @@ Feature: Collections
|
|||
And I should see 'Article: Blog3 Another Article'
|
||||
And I should see 'Article: Blog2 Yet Another Article'
|
||||
|
||||
Scenario: Work with local helpers
|
||||
Given a fixture app "collections-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
module TestHelper
|
||||
def help_me
|
||||
"ok"
|
||||
end
|
||||
end
|
||||
|
||||
include TestHelper
|
||||
|
||||
data.articles.each_with_index do |a, i|
|
||||
proxy "/#{i}-#{help_me}.html", a
|
||||
end
|
||||
"""
|
||||
And a file named "data/articles.yaml" with:
|
||||
"""
|
||||
---
|
||||
- "/blog1/2011-01-01-new-article.html"
|
||||
- "/blog2/2011-01-02-another-article.html"
|
||||
"""
|
||||
Given the Server is running at "collections-app"
|
||||
When I go to "0-ok.html"
|
||||
Then I should see 'Newer Article Content'
|
||||
When I go to "1-ok.html"
|
||||
Then I should see 'Another Article Content'
|
||||
|
||||
Scenario: Collected data update with file changes
|
||||
Given a fixture app "collections-app"
|
||||
|
|
|
@ -90,7 +90,7 @@ module Middleman
|
|||
pair[:root].realize!(dataset)
|
||||
end
|
||||
|
||||
ctx = StepContext.new
|
||||
ctx = StepContext.new(app)
|
||||
StepContext.current = ctx
|
||||
|
||||
leaves = @leaves.dup
|
||||
|
|
|
@ -12,17 +12,20 @@ module Middleman
|
|||
|
||||
attr_reader :descriptors
|
||||
|
||||
def initialize
|
||||
def initialize(app)
|
||||
@app = app
|
||||
@descriptors = []
|
||||
end
|
||||
|
||||
def method_missing(name, *args, &block)
|
||||
internal = :"_internal_#{name}"
|
||||
|
||||
return super unless respond_to?(internal)
|
||||
|
||||
send(internal, *args, &block).tap do |r|
|
||||
@descriptors << r if r.respond_to?(:execute_descriptor)
|
||||
if respond_to?(internal)
|
||||
send(internal, *args, &block).tap do |r|
|
||||
@descriptors << r if r.respond_to?(:execute_descriptor)
|
||||
end
|
||||
else
|
||||
@app.config_context.send(name, *args, &block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue