make decorators be kind_of their models class, so that cancan rules
apply to them
This commit is contained in:
parent
ad94f54369
commit
ac1f308398
|
@ -146,6 +146,11 @@ module Draper
|
|||
@model == (other.respond_to?(:model) ? other.model : other)
|
||||
end
|
||||
|
||||
def kind_of?(klass)
|
||||
return true if klass == model.class
|
||||
super
|
||||
end
|
||||
|
||||
def respond_to?(method, include_private = false)
|
||||
super || (allow?(method) && model.respond_to?(method))
|
||||
end
|
||||
|
|
|
@ -362,4 +362,10 @@ describe Draper::Base do
|
|||
decorator.sample_truncate.should == "Once..."
|
||||
end
|
||||
end
|
||||
|
||||
describe "decorator in cancan rules" do
|
||||
it "should answer yes to kind_of? source class" do
|
||||
subject.kind_of?(source.class).should == true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue