Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #175 from nashby/fix-issue-173
prevent double decoration
  • Loading branch information
steveklabnik committed Apr 23, 2012
2 parents eaecb62 + c945cce commit 3a176b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/draper/base.rb
Expand Up @@ -26,7 +26,7 @@ class Base
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

Expand Down
5 changes: 5 additions & 0 deletions spec/draper/base_spec.rb
Expand Up @@ -44,6 +44,11 @@
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
Expand Down

0 comments on commit 3a176b0

Please sign in to comment.