1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

Adding context to find, closes #28

This commit is contained in:
Jeff Casimir 2011-10-03 18:10:25 -04:00
parent f1d61a6d0f
commit 1e2868648b
2 changed files with 7 additions and 2 deletions

View file

@ -32,8 +32,8 @@ module Draper
#
# @param [Symbol or String] id to lookup
# @return [Object] instance of this decorator class
def self.find(input)
self.new(model_class.find(input))
def self.find(input, context = {})
self.new(model_class.find(input), context)
end
# Typically called within a decorator definition, this method

View file

@ -89,6 +89,11 @@ describe Draper::Base do
pd.should be_instance_of(ProductDecorator)
pd.model.should be_instance_of(Product)
end
it "should accept and store a context" do
pd = ProductDecorator.find(1, :admin)
pd.context.should == :admin
end
end
context ".decorate" do