Force id to be proxied to the model
This commit is contained in:
parent
f55962ddcb
commit
01c8de21c0
|
@ -5,7 +5,7 @@ module Draper
|
|||
attr_accessor :context, :model
|
||||
|
||||
DEFAULT_DENIED = Object.new.methods << :method_missing
|
||||
FORCED_PROXY = [:to_param]
|
||||
FORCED_PROXY = [:to_param, :id]
|
||||
FORCED_PROXY.each do |method|
|
||||
define_method method do |*args, &block|
|
||||
model.send method, *args, &block
|
||||
|
|
|
@ -74,6 +74,11 @@ describe Draper::Base do
|
|||
Draper::Base.new(source).to_param.should == 1
|
||||
end
|
||||
|
||||
it "should always proxy id" do
|
||||
source.send :class_eval, "def id; 123456789; end"
|
||||
Draper::Base.new(source).id.should == 123456789
|
||||
end
|
||||
|
||||
it "should not copy the .class, .inspect, or other existing methods" do
|
||||
source.class.should_not == subject.class
|
||||
source.inspect.should_not == subject.inspect
|
||||
|
|
Loading…
Reference in New Issue