Commit Graph

30 Commits

Author SHA1 Message Date
Bartek Bułat 387878f39c Clean view context when controller changes (#799)
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`.
2017-05-08 09:23:13 -05:00
Cliff Braton bcf6bdcf4a Remove previously deprecated functionality. (#785) 2017-03-29 10:26:07 -05:00
Yuichiro Kaneko 9b6106fed0 Fix warning message from `controller` to `controller=` (#694) 2017-03-28 08:47:24 -05:00
Thibault Jouan 50dea101b2 Remove executable bit from lib and spec source files (#718) 2017-03-27 22:39:17 -05:00
Tieg Zaharia 18ddae30dd Set the controller properly 2014-06-01 11:54:45 -04:00
Tieg Zaharia d3cbec8283 Don't think clear! is necessary, and give before_filter a name 2014-06-01 11:54:45 -04:00
Andrew Haines 50a3435acb Store helper proxies instead of raw view contexts
Closes #436.
2013-01-24 00:23:39 +00:00
Andrew Haines a039671202 Add support for decoupled specs
Closes #424
2013-01-19 21:55:46 +00:00
Steve Klabnik fde1cde9ad Integrate RequestStore.
Fixes #390
2012-12-17 03:44:12 -07:00
Andrew Haines 606cfeb93b Simplify railtie 2012-11-15 23:08:21 +00:00
Andrew Haines c5b027d347 Fix view context
Closes #313
2012-11-12 20:00:00 +00:00
Steve Klabnik abcb33fdd8 Set host for ActionMailer instances.
Fixes #256.

I'm not happy with this, but at least it works. For now.
2012-10-08 21:01:04 -07:00
Chris Heald 6e6217a484 Clear the context per request, and assign a controller reference that is used to create a new view context on demand if needed by draper outside of a template context. Fixes #287. Split out the system initialization into action_controller and action_mailer pieces for clarity. Guarded the view context lazy initialization to only attempt to create a test context if the proper test classes exist (as they won't outside of test mode). 2012-10-01 14:30:18 -07:00
sankaranarayanan 12bf16f051 cleaned up the spec 2012-09-24 22:55:04 +05:30
sankaranarayanan c12592a1de Fixed bug build_view_context should be class method 2012-09-24 22:21:08 +05:30
Rein Henrichs 91d0b67654 Separate ViewContext get/create context behavior
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.
2012-08-29 11:50:49 -07:00
Steve Klabnik 8b00deae68 Let's actually memoize that, shall we? 2012-08-29 10:56:28 -07:00
Steve Klabnik 5551fbc29e Remove #tap.
@reinh points out that this is a bug
2012-08-29 09:42:48 -07:00
Steve Klabnik dc1b9a11cd Revert "Break reliance on ActionController."
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.
2012-08-28 22:57:15 -07:00
Steve Klabnik b3a2af7488 Break reliance on ActionController.
Originally brought up in #249, I didn't know how to fix this.

But now I do.
2012-08-28 22:47:16 -07:00
Steve Klabnik 1dcbe68ee8 Totally change test integration.
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. :)
2012-08-28 22:42:38 -07:00
Istvan Hoka 8e505565f9 Fixed view_context priming. Fixes #244, relates to 057ab4e8.
Fix in 057ab4e8 resulted in a "NameError: undefined local variable or method `view_context' for Draper::ViewContext:Module".
2012-08-14 14:18:14 +03:00
Steve Klabnik 057ab4e86f Set view_context if it's nil.
This should take care of #244, but also in general, anywhere
that we haven't primed the context yet.
2012-08-11 15:45:35 -07:00
Ryan Fitzgerald 5b9288b3f6 Move view_context definition back into System.setup 2012-07-18 17:58:12 -07:00
Steve Klabnik 0b03d9c21e Monkeypatch ActionController::Base.
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 #124
Fixes #109
2012-07-17 09:40:52 -04:00
Benny Wong c56ac5ed2c Include Draper::ViewContextFilter in ActionMailer::Base
* Only send the :before_filter method if it exists
* This will allow decorators to be used when rendering email
2011-10-28 13:29:48 -04:00
Jeff Casimir f50a82795c Abstracting Thread.current implementation detail 2011-10-20 03:32:26 -04:00
Mattias Pfeiffer ea445dd2d3 Set the view_context properly 2011-10-13 18:12:42 +02:00
Jeff Casimir e350a9a85d Simplified structure after testing in an actual app 2011-10-08 01:37:33 -04:00
Jeff Casimir 39fc5c9513 Rewrote technique for getting view_context/helper access 2011-10-08 01:06:19 -04:00