We no longer need to do specific things before tests run. The
view_context now loads up appropriate things if they don't exist.
I ended up getting rid of two spec files; one tested things that
were very simple, but since we're not mocking Rails anymore, they're
much harder to test. The second was the stuff that I removed. :)
We need to be able to let draper get a copy of the view_context
no matter what happens. AC::Base doesn't really let us do that. So
we have to monkeypatch.
This was originally suggested in
https://github.com/jcasimir/draper/issues/124#issuecomment-6954291
by @rf-.
It appears to be the cleanest way to take care of this problem, and
shouldn't affect any other things, since we keep the exact same
semantics of view_context.
Theoretically:
Fixes#124Fixes#109
The goal here is to improve ActiveModel support so that Draper can
work seamlessly with Rails' FormHelpers, proxying the model's #errors
method.
I also added support for ActiveModel::Errors, adding a proxy to the
model's #errors method only if it's a descendant of
ActiveModel::Validations.
Also some refactoring was done. Draper now proxies #to_param and #id
methods only if the model is an ActiveModel descendant.
Other things I did include:
- created Draper::ActiveModelSupport::Proxies, which contains the
methods for proxying default methods(to_param, id, etc) depending
on the ancestors
- wrote specs for class with ActiveModel as ancestor
- wrote specs for class without ActiveModel as ancestor