mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Merge pull request #145 from avdgaag/fix-for-kernel-array
Bugfix: do not confuse Kernel#Array
This commit is contained in:
commit
89126e48d6
2 changed files with 12 additions and 4 deletions
|
@ -204,11 +204,15 @@ module Draper
|
|||
def method_missing(method, *args, &block)
|
||||
super unless allow?(method)
|
||||
|
||||
self.class.send :define_method, method do |*args, &block|
|
||||
model.send method, *args, &block
|
||||
end
|
||||
if model.respond_to?(method)
|
||||
self.class.send :define_method, method do |*args, &block|
|
||||
model.send method, *args, &block
|
||||
end
|
||||
|
||||
send method, *args, &block
|
||||
send method, *args, &block
|
||||
else
|
||||
super
|
||||
end
|
||||
|
||||
rescue NoMethodError => no_method_error
|
||||
super if no_method_error.name == method
|
||||
|
|
|
@ -622,6 +622,10 @@ describe Draper::Base do
|
|||
end
|
||||
|
||||
context "when the delegated method calls a non-existant method" do
|
||||
it 'should not try to delegate to non-existant methods to not confuse Kernel#Array' do
|
||||
Array(subject).should be_kind_of(Array)
|
||||
end
|
||||
|
||||
it "raises the correct NoMethodError" do
|
||||
begin
|
||||
subject.some_action
|
||||
|
|
Loading…
Reference in a new issue