When we reassign controller it is the right thing to do to clear current
view context stored in request store. Consider a case when view context
was built before the request was made (usage of `h` helper in class level
context). View context is built from default controller and has no
information about the request. During first request
`Draper::ViewContext.current.controller` will be different than
`Draper::ViewContext.controller`.
Separating these behaviors eliminates and entire class of bugs like forgetting to re-set the thread local, attempting to re-set the block-local conditionally, and so on. It also makes it more obvious that `self.current` is memoizing.
This reverts commit b3a2af7488.
Basically, we have an issue with ActionMailer::Base. Given this
code, we end up with
```
private method `new' called for ActionMailer::Base:Class
```
And That's Bad (tm).
Still that commit should point the way to making it happen somehow.
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