mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
kill set_current_view_context
This commit is contained in:
parent
19ecb66d07
commit
1d6491b4c7
4 changed files with 6 additions and 6 deletions
|
@ -244,19 +244,19 @@ Use the new methods in your views like any other model method (ex: `@article.pub
|
|||
|
||||
### Using in Mailers
|
||||
|
||||
To use decorators in mailers that use helpers, you have to call `set_current_view_context` in your
|
||||
To use decorators in mailers that use helpers, you have to call `view_context` in your
|
||||
ActionMailer class.
|
||||
|
||||
```ruby
|
||||
class ArticleMailer < ActionMailer::Base
|
||||
default 'init-draper' => Proc.new { set_current_view_context }
|
||||
default 'init-draper' => Proc.new { ArticleMailer.new.view_context }
|
||||
end
|
||||
```
|
||||
### Integration with RSpec
|
||||
|
||||
Using the provided generator, Draper will place specs for your new decorator in `spec/decorators/`.
|
||||
|
||||
By default, specs in `spec/decorators` will be tagged as `type => :decorator`. Any spec tagged as `decorator` will run `ApplicationController.new.set_current_view_context` which makes helpers available to the decorator.
|
||||
By default, specs in `spec/decorators` will be tagged as `type => :decorator`. Any spec tagged as `decorator` will make helpers available to the decorator.
|
||||
|
||||
If your decorator specs live somewhere else, which they shouldn't, make sure to tag them with `type => :decorator`. If you don't tag them, Draper's helpers won't be available to your decorator while testing.
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ module Draper
|
|||
|
||||
console do
|
||||
require 'action_controller/test_case'
|
||||
ApplicationController.new.set_current_view_context
|
||||
ApplicationController.new.view_context
|
||||
Draper::ViewContext.current.controller.request ||= ActionController::TestRequest.new
|
||||
Draper::ViewContext.current.request ||= Draper::ViewContext.current.controller.request
|
||||
Draper::ViewContext.current.params ||= {}
|
||||
|
|
|
@ -19,7 +19,7 @@ RSpec.configure do |config|
|
|||
end
|
||||
|
||||
config.before :type => :view do
|
||||
controller.set_current_view_context
|
||||
controller.view_context
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@ require 'test_helper'
|
|||
|
||||
class <%= class_name %>DecoratorTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
ApplicationController.new.set_current_view_context
|
||||
ApplicationController.new.view_context
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue