mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Remove unnecessary view_context setup
This commit is contained in:
parent
5b9288b3f6
commit
75a8204148
3 changed files with 6 additions and 16 deletions
|
@ -233,7 +233,7 @@ ArticleDecorator.decorate(Article.all) # Returns an enumeration proxy of Artic
|
|||
```ruby
|
||||
ArticleDecorator.find(1)
|
||||
```
|
||||
|
||||
|
||||
### In Your Views
|
||||
|
||||
Use the new methods in your views like any other model method (ex: `@article.published_at`):
|
||||
|
@ -242,16 +242,6 @@ Use the new methods in your views like any other model method (ex: `@article.pub
|
|||
<h1><%= @article.title %> <%= @article.published_at %></h1>
|
||||
```
|
||||
|
||||
### Using in Mailers
|
||||
|
||||
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 { ArticleMailer.new.view_context }
|
||||
end
|
||||
```
|
||||
### Integration with RSpec
|
||||
|
||||
Using the provided generator, Draper will place specs for your new decorator in `spec/decorators/`.
|
||||
|
|
|
@ -17,10 +17,6 @@ RSpec.configure do |config|
|
|||
config.before :type => :decorator do
|
||||
Draper::ViewContext.infect!(self)
|
||||
end
|
||||
|
||||
config.before :type => :view do
|
||||
controller.view_context
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(Capybara)
|
||||
|
@ -30,4 +26,3 @@ if defined?(Capybara)
|
|||
config.include Capybara::RSpecMatchers, :type => :decorator
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,4 +8,9 @@ describe Draper::ViewContext do
|
|||
it "provides a method to create a view context while testing" do
|
||||
Draper::ViewContext.should respond_to(:infect!)
|
||||
end
|
||||
|
||||
it "copies the controller's view context to draper" do
|
||||
ctx = app_controller_instance.view_context
|
||||
Draper::ViewContext.current.should == ctx
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue