prevent double decoration, closes #173
This commit is contained in:
parent
eaecb62b36
commit
c945cce6f3
|
@ -26,7 +26,7 @@ module Draper
|
|||
def initialize(input, options = {})
|
||||
input.inspect # forces evaluation of a lazy query from AR
|
||||
self.class.model_class = input.class if model_class.nil?
|
||||
@model = input
|
||||
@model = input.kind_of?(Draper::Base) ? input.model : input
|
||||
self.options = options
|
||||
end
|
||||
|
||||
|
|
|
@ -44,6 +44,11 @@ describe Draper::Base do
|
|||
ProductDecorator.new(source).model_class.should == Product
|
||||
end
|
||||
|
||||
it "returns decorator if it's decorated model already" do
|
||||
product_decorator = ProductDecorator.new(source)
|
||||
ProductDecorator.new(product_decorator).model.should be_instance_of Product
|
||||
end
|
||||
|
||||
it "should handle plural-like words properly'" do
|
||||
class Business; end
|
||||
expect do
|
||||
|
|
Loading…
Reference in New Issue