0

I recently upgraded the Draper gem to 1.2.1. I was previously checking to see what fields were allowed via:

class MyDecorator < Draper::Decorator
  allows :email
end

...spec...

MyDecorator.allowed.should == [:email]

Apparently "allows" is now delegates, what is "allowed"?

Allyl Isocyanate
  • 13,306
  • 17
  • 79
  • 130
  • Before Draper delegated everything and you had to use security methods like `allows :email` to restrict this. Now Draper makes you either `delegate_all` or specifically say what you want delegated like `delegate :email`. If you don't include `delegate_all` you don't need to test for anything because Draper doesn't delegate anything. If you specifically then delegate something, you can just check that you have access to that method in your test. – Alex Peachey Oct 01 '13 at 23:03
  • Yeah, in my usecase I was creating an anonymized snapshot of my database, and using a draper decorator to determine if a field on a particular model should be anonymized. The allowed method was what I used to figure that out. Unfortunately doing "respond_to?" all over the place isn't great/won't work, so I ended up re-implementing allowed on my own. – Allyl Isocyanate Oct 02 '13 at 16:36

0 Answers0