draper 4.0.2 → 4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -2
- data/CHANGELOG.md +24 -0
- data/README.md +26 -7
- data/lib/draper/automatic_delegation.rb +14 -4
- data/lib/draper/collection_decorator.rb +0 -6
- data/lib/draper/compatibility/broadcastable.rb +24 -0
- data/lib/draper/compatibility/global_id.rb +9 -5
- data/lib/draper/decoratable/collection_proxy.rb +15 -0
- data/lib/draper/decoratable.rb +7 -2
- data/lib/draper/decorator.rb +2 -18
- data/lib/draper/query_methods.rb +1 -1
- data/lib/draper/railtie.rb +14 -5
- data/lib/draper/version.rb +1 -1
- data/lib/draper/view_context/build_strategy.rb +1 -9
- data/lib/draper.rb +0 -6
- metadata +16 -235
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -24
- data/.github/workflows/ci.yml +0 -55
- data/.gitignore +0 -18
- data/Gemfile +0 -24
- data/bin/bundle +0 -114
- data/bin/rake +0 -29
- data/draper.gemspec +0 -34
- data/spec/draper/collection_decorator_spec.rb +0 -291
- data/spec/draper/configuration_spec.rb +0 -49
- data/spec/draper/decoratable/equality_spec.rb +0 -10
- data/spec/draper/decoratable_spec.rb +0 -235
- data/spec/draper/decorated_association_spec.rb +0 -82
- data/spec/draper/decorates_assigned_spec.rb +0 -71
- data/spec/draper/decorator_spec.rb +0 -872
- data/spec/draper/draper_spec.rb +0 -25
- data/spec/draper/factory_spec.rb +0 -247
- data/spec/draper/finders_spec.rb +0 -166
- data/spec/draper/helper_proxy_spec.rb +0 -61
- data/spec/draper/lazy_helpers_spec.rb +0 -21
- data/spec/draper/query_methods/load_strategy_spec.rb +0 -26
- data/spec/draper/query_methods_spec.rb +0 -70
- data/spec/draper/undecorate_chain_spec.rb +0 -20
- data/spec/draper/undecorate_spec.rb +0 -19
- data/spec/draper/view_context/build_strategy_spec.rb +0 -132
- data/spec/draper/view_context_spec.rb +0 -182
- data/spec/draper/view_helpers_spec.rb +0 -8
- data/spec/dummy/.rspec +0 -2
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/config/manifest.js +0 -3
- data/spec/dummy/app/controllers/application_controller.rb +0 -2
- data/spec/dummy/app/controllers/base_controller.rb +0 -4
- data/spec/dummy/app/controllers/localized_urls.rb +0 -5
- data/spec/dummy/app/controllers/posts_controller.rb +0 -20
- data/spec/dummy/app/decorators/mongoid_post_decorator.rb +0 -4
- data/spec/dummy/app/decorators/post_decorator.rb +0 -60
- data/spec/dummy/app/helpers/application_helper.rb +0 -5
- data/spec/dummy/app/jobs/publish_post_job.rb +0 -7
- data/spec/dummy/app/mailers/application_mailer.rb +0 -3
- data/spec/dummy/app/mailers/post_mailer.rb +0 -19
- data/spec/dummy/app/models/admin.rb +0 -5
- data/spec/dummy/app/models/application_record.rb +0 -3
- data/spec/dummy/app/models/mongoid_post.rb +0 -5
- data/spec/dummy/app/models/post.rb +0 -3
- data/spec/dummy/app/models/user.rb +0 -5
- data/spec/dummy/app/views/layouts/application.html.erb +0 -11
- data/spec/dummy/app/views/post_mailer/decorated_email.html.erb +0 -1
- data/spec/dummy/app/views/posts/_post.html.erb +0 -42
- data/spec/dummy/app/views/posts/show.html.erb +0 -1
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/config/application.rb +0 -68
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -35
- data/spec/dummy/config/environments/production.rb +0 -59
- data/spec/dummy/config/environments/test.rb +0 -35
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/draper.rb +0 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -8
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/mongoid.yml +0 -142
- data/spec/dummy/config/routes.rb +0 -9
- data/spec/dummy/config/storage.yml +0 -7
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/migrate/20121019115657_create_posts.rb +0 -8
- data/spec/dummy/db/schema.rb +0 -21
- data/spec/dummy/db/seeds.rb +0 -2
- data/spec/dummy/fast_spec/post_decorator_spec.rb +0 -37
- data/spec/dummy/lib/tasks/test.rake +0 -16
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/dummy/spec/decorators/active_model_serializers_spec.rb +0 -12
- data/spec/dummy/spec/decorators/devise_spec.rb +0 -55
- data/spec/dummy/spec/decorators/helpers_spec.rb +0 -21
- data/spec/dummy/spec/decorators/post_decorator_spec.rb +0 -64
- data/spec/dummy/spec/decorators/spec_type_spec.rb +0 -7
- data/spec/dummy/spec/decorators/view_context_spec.rb +0 -22
- data/spec/dummy/spec/jobs/publish_post_job_spec.rb +0 -9
- data/spec/dummy/spec/mailers/post_mailer_spec.rb +0 -25
- data/spec/dummy/spec/models/application_spec.rb +0 -7
- data/spec/dummy/spec/models/mongoid_post_spec.rb +0 -8
- data/spec/dummy/spec/models/post_spec.rb +0 -15
- data/spec/dummy/spec/shared_examples/decoratable.rb +0 -22
- data/spec/dummy/spec/spec_helper.rb +0 -8
- data/spec/dummy/test/decorators/minitest/devise_test.rb +0 -55
- data/spec/dummy/test/decorators/minitest/helpers_test.rb +0 -21
- data/spec/dummy/test/decorators/minitest/spec_type_test.rb +0 -52
- data/spec/dummy/test/decorators/minitest/view_context_test.rb +0 -24
- data/spec/dummy/test/decorators/test_unit/devise_test.rb +0 -55
- data/spec/dummy/test/decorators/test_unit/helpers_test.rb +0 -21
- data/spec/dummy/test/decorators/test_unit/view_context_test.rb +0 -24
- data/spec/dummy/test/minitest_helper.rb +0 -2
- data/spec/dummy/test/test_helper.rb +0 -3
- data/spec/generators/controller/controller_generator_spec.rb +0 -23
- data/spec/generators/decorator/decorator_generator_spec.rb +0 -93
- data/spec/generators/install/install_generator_spec.rb +0 -19
- data/spec/integration/integration_spec.rb +0 -70
- data/spec/performance/active_record.rb +0 -4
- data/spec/performance/benchmark.rb +0 -55
- data/spec/performance/decorators.rb +0 -45
- data/spec/performance/models.rb +0 -20
- data/spec/spec_helper.rb +0 -50
- data/spec/support/dummy_app.rb +0 -85
- data/spec/support/matchers/have_text.rb +0 -50
- data/spec/support/shared_examples/decoratable_equality.rb +0 -40
- data/spec/support/shared_examples/view_helpers.rb +0 -39
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 01d36de260431b65888e966e0ae86d336da78fb154c016e3e1871c07db8b1502
|
|
4
|
+
data.tar.gz: 773cef0abfa87de807d460dca408a86d1aa9f34e2e652486c6b242c9819ad178
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bc3e685a475539225c88e1d7cc44575ec5ce59872ddd1babede55eb9a07c323a2fa267e3d35d55d2c009a12948e83273150c132829597c8bc641c99c15445f7b
|
|
7
|
+
data.tar.gz: 37670673d87b1fea1b93bf435756d1ddaee6da897c1f3905c9aaec7c1b7dab6e02cb3ea9c52ab106a98b54c0e254c1f0e2d8fddaab0ba539a8a308b9cbdd58ea
|
data/.rspec
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
--
|
|
2
|
-
--order rand
|
|
1
|
+
--format progress
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Draper Changelog
|
|
2
2
|
|
|
3
|
+
## 4.0.5 - 2025-11-12
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
* Remove unused files from package [#945](https://github.com/drapergem/draper/pull/945)
|
|
7
|
+
* Support Rails 8.1 [#949](https://github.com/drapergem/draper/pull/949)
|
|
8
|
+
|
|
9
|
+
## 4.0.4 - 2025-01-28
|
|
10
|
+
|
|
11
|
+
### Fixes
|
|
12
|
+
* Fix a `LoadError` caused by a cherry-pick issue in version 4.0.3
|
|
13
|
+
|
|
14
|
+
## 4.0.3 - 2025-01-27
|
|
15
|
+
|
|
16
|
+
Added support for latest Ruby (upto 3.4) and Rails (upto 8) versions.
|
|
17
|
+
|
|
18
|
+
### Fixes
|
|
19
|
+
* Fix `CollectionDecorator#respond_to?` for non-ORM collections [#920](https://github.com/drapergem/draper/pull/920)
|
|
20
|
+
* Fix issues with using Draper outside of controller scope [#927](https://github.com/drapergem/draper/pull/927)
|
|
21
|
+
* Fix decoration of AR associations [#932](https://github.com/drapergem/draper/pull/932)
|
|
22
|
+
|
|
23
|
+
### Other Changes
|
|
24
|
+
* Improve performance of delegation via `delegate_all` [#911](https://github.com/drapergem/draper/pull/911)
|
|
25
|
+
* Improve README [#878](https://github.com/drapergem/draper/pull/878), [#922](https://github.com/drapergem/draper/pull/922), [#934](https://github.com/drapergem/draper/pull/934)
|
|
26
|
+
|
|
3
27
|
## 4.0.2 - 2021-05-27
|
|
4
28
|
|
|
5
29
|
### Fixes
|
data/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# Draper: View Models for Rails
|
|
2
2
|
|
|
3
|
-
[](https://codeclimate.com/github/drapergem/draper)
|
|
5
|
-
[](https://codeclimate.com/github/drapergem/draper/test_coverage)
|
|
3
|
+
[](https://github.com/drapergem/draper/actions?query=workflow%3Aci+branch%3Amaster)
|
|
6
4
|
[](http://inch-ci.org/github/drapergem/draper)
|
|
7
5
|
|
|
8
6
|
Draper adds an object-oriented layer of presentation logic to your Rails
|
|
@@ -131,6 +129,17 @@ class ArticleDecorator < Draper::Decorator
|
|
|
131
129
|
end
|
|
132
130
|
```
|
|
133
131
|
|
|
132
|
+
|
|
133
|
+
To decorate a model in a namespace e.g. `Admin::Catalogue` place the decorator under the
|
|
134
|
+
directory `app/decorators/admin` in the same way you would with views and models.
|
|
135
|
+
|
|
136
|
+
```ruby
|
|
137
|
+
# app/decorators/admin/catalogue_decorator.rb
|
|
138
|
+
class Admin::CatalogueDecorator < Draper::Decorator
|
|
139
|
+
# ...
|
|
140
|
+
end
|
|
141
|
+
```
|
|
142
|
+
|
|
134
143
|
### Generators
|
|
135
144
|
|
|
136
145
|
To create an `ApplicationDecorator` that all generated decorators inherit from, run...
|
|
@@ -155,6 +164,15 @@ rails generate decorator Article
|
|
|
155
164
|
|
|
156
165
|
...to create the `ArticleDecorator`.
|
|
157
166
|
|
|
167
|
+
If you don't want Rails to generate decorator files when generating a new controller,
|
|
168
|
+
you can add the following configuration to your `config/application.rb` file:
|
|
169
|
+
|
|
170
|
+
```ruby
|
|
171
|
+
config.generators do |g|
|
|
172
|
+
g.decorator false
|
|
173
|
+
end
|
|
174
|
+
```
|
|
175
|
+
|
|
158
176
|
### Accessing Helpers
|
|
159
177
|
|
|
160
178
|
Normal Rails helpers are still useful for lots of tasks. Both Rails' provided
|
|
@@ -652,9 +670,8 @@ you can include this module manually.
|
|
|
652
670
|
[Active Job](http://edgeguides.rubyonrails.org/active_job_basics.html) allows you to pass ActiveRecord
|
|
653
671
|
objects to background tasks directly and performs the necessary serialization and deserialization. In
|
|
654
672
|
order to do this, arguments to a background job must implement [Global ID](https://github.com/rails/globalid).
|
|
655
|
-
|
|
656
|
-
you can pass decorated objects to background jobs,
|
|
657
|
-
deserialized.
|
|
673
|
+
Decorators implement Global ID.
|
|
674
|
+
This means you can pass decorated objects to background jobs, and get them just as decorated when deserialized.
|
|
658
675
|
|
|
659
676
|
## Contributors
|
|
660
677
|
|
|
@@ -664,7 +681,8 @@ great community of open source
|
|
|
664
681
|
|
|
665
682
|
### Current maintainers
|
|
666
683
|
|
|
667
|
-
*
|
|
684
|
+
* Alexander Senko (Alexander.Senko@gmail.com)
|
|
685
|
+
* Yuji Yaginuma (yuuji.yaginuma@gmail.com)
|
|
668
686
|
|
|
669
687
|
### Historical maintainers
|
|
670
688
|
|
|
@@ -673,3 +691,4 @@ great community of open source
|
|
|
673
691
|
* Vasiliy Ermolovich
|
|
674
692
|
* Andrew Haines
|
|
675
693
|
* Sean Linsley
|
|
694
|
+
* Cliff Braton (cliff.braton@gmail.com)
|
|
@@ -18,11 +18,21 @@ module Draper
|
|
|
18
18
|
super || delegatable?(method)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
# The inherit argument for `private_method_defined?` is supported since Ruby 2.6.
|
|
22
|
+
if RUBY_VERSION >= "2.6"
|
|
23
|
+
# @private
|
|
24
|
+
def delegatable?(method)
|
|
25
|
+
return if self.class.private_method_defined?(method, false)
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
object.respond_to?(method)
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
# @private
|
|
31
|
+
def delegatable?(method)
|
|
32
|
+
return if private_methods(false).include?(method)
|
|
33
|
+
|
|
34
|
+
object.respond_to?(method)
|
|
35
|
+
end
|
|
26
36
|
end
|
|
27
37
|
|
|
28
38
|
module ClassMethods
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Draper
|
|
4
|
+
module Compatibility
|
|
5
|
+
# It would look consistent to use decorated objects inside templates broadcasted with
|
|
6
|
+
# Turbo::Broadcastable.
|
|
7
|
+
#
|
|
8
|
+
# This compatibility patch fixes the issue by overriding the original defaults to decorate the
|
|
9
|
+
# object, that's passed to the partial in a local variable.
|
|
10
|
+
module Broadcastable
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def broadcast_rendering_with_defaults(options)
|
|
14
|
+
return super unless decorator_class?
|
|
15
|
+
|
|
16
|
+
# Add the decorated current instance into the locals (see original method for details).
|
|
17
|
+
options[:locals] =
|
|
18
|
+
(options[:locals] || {}).reverse_merge!(model_name.element.to_sym => decorate)
|
|
19
|
+
|
|
20
|
+
super
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -5,17 +5,21 @@ module Draper
|
|
|
5
5
|
# and deserialization. In order to do this, arguments to a background job must implement
|
|
6
6
|
# [Global ID](https://github.com/rails/globalid).
|
|
7
7
|
#
|
|
8
|
-
# This compatibility patch implements Global ID for decorated objects by
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
8
|
+
# This compatibility patch implements Global ID for decorated objects by defining `.find(id)`
|
|
9
|
+
# class method that uses the original one and decorates the result.
|
|
10
|
+
# This means you can pass decorated objects to background jobs and they will be decorated when
|
|
11
|
+
# deserialized.
|
|
12
12
|
module GlobalID
|
|
13
13
|
extend ActiveSupport::Concern
|
|
14
14
|
|
|
15
15
|
included do
|
|
16
16
|
include ::GlobalID::Identification
|
|
17
|
+
end
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
class_methods do
|
|
20
|
+
def find(*args)
|
|
21
|
+
object_class.find(*args).decorate
|
|
22
|
+
end
|
|
19
23
|
end
|
|
20
24
|
end
|
|
21
25
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Draper
|
|
2
|
+
module Decoratable
|
|
3
|
+
module CollectionProxy
|
|
4
|
+
# Decorates a collection of objects. Used at the end of a scope chain.
|
|
5
|
+
#
|
|
6
|
+
# @example
|
|
7
|
+
# company.products.popular.decorate
|
|
8
|
+
# @param [Hash] options
|
|
9
|
+
# see {Decorator.decorate_collection}.
|
|
10
|
+
def decorate(options = {})
|
|
11
|
+
decorator_class.decorate_collection(load_target, options.reverse_merge(with: nil))
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/draper/decoratable.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'draper/decoratable/equality'
|
|
2
|
+
require 'draper/compatibility/broadcastable'
|
|
2
3
|
|
|
3
4
|
module Draper
|
|
4
5
|
# Provides shortcuts to decorate objects directly, so you can do
|
|
@@ -11,6 +12,12 @@ module Draper
|
|
|
11
12
|
extend ActiveSupport::Concern
|
|
12
13
|
include Draper::Decoratable::Equality
|
|
13
14
|
|
|
15
|
+
autoload :CollectionProxy, 'draper/decoratable/collection_proxy'
|
|
16
|
+
|
|
17
|
+
included do
|
|
18
|
+
prepend Draper::Compatibility::Broadcastable if defined? Turbo::Broadcastable
|
|
19
|
+
end
|
|
20
|
+
|
|
14
21
|
# Decorates the object using the inferred {#decorator_class}.
|
|
15
22
|
# @param [Hash] options
|
|
16
23
|
# see {Decorator#initialize}
|
|
@@ -87,8 +94,6 @@ module Draper
|
|
|
87
94
|
def ===(other)
|
|
88
95
|
super || (other.is_a?(Draper::Decorator) && super(other.object))
|
|
89
96
|
end
|
|
90
|
-
|
|
91
97
|
end
|
|
92
|
-
|
|
93
98
|
end
|
|
94
99
|
end
|
data/lib/draper/decorator.rb
CHANGED
|
@@ -33,7 +33,7 @@ module Draper
|
|
|
33
33
|
options.assert_valid_keys(:context)
|
|
34
34
|
@object = object
|
|
35
35
|
@context = options.fetch(:context, {})
|
|
36
|
-
handle_multiple_decoration(options) if object.
|
|
36
|
+
handle_multiple_decoration(options) if object.is_a?(Draper::Decorator)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
class << self
|
|
@@ -185,22 +185,6 @@ module Draper
|
|
|
185
185
|
self.class.hash ^ object.hash
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
-
# Checks if `self.kind_of?(klass)` or `object.kind_of?(klass)`
|
|
189
|
-
#
|
|
190
|
-
# @param [Class] klass
|
|
191
|
-
def kind_of?(klass)
|
|
192
|
-
super || object.kind_of?(klass)
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
alias :is_a? :kind_of?
|
|
196
|
-
|
|
197
|
-
# Checks if `self.instance_of?(klass)` or `object.instance_of?(klass)`
|
|
198
|
-
#
|
|
199
|
-
# @param [Class] klass
|
|
200
|
-
def instance_of?(klass)
|
|
201
|
-
super || object.instance_of?(klass)
|
|
202
|
-
end
|
|
203
|
-
|
|
204
188
|
delegate :to_s
|
|
205
189
|
|
|
206
190
|
# In case object is nil
|
|
@@ -267,7 +251,7 @@ module Draper
|
|
|
267
251
|
if object.applied_decorators.last == self.class
|
|
268
252
|
@context = object.context unless options.has_key?(:context)
|
|
269
253
|
@object = object.object
|
|
270
|
-
|
|
254
|
+
elsif object.applied_decorators.include?(self.class)
|
|
271
255
|
warn "Reapplying #{self.class} decorator to target that is already decorated with it. Call stack:\n#{caller(1).join("\n")}"
|
|
272
256
|
end
|
|
273
257
|
end
|
data/lib/draper/query_methods.rb
CHANGED
data/lib/draper/railtie.rb
CHANGED
|
@@ -33,10 +33,14 @@ module Draper
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
initializer 'draper.setup_orm' do
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
ActiveSupport.on_load :active_record do
|
|
37
|
+
include Draper::Decoratable
|
|
38
|
+
|
|
39
|
+
ActiveRecord::Associations::CollectionProxy.include Draper::Decoratable::CollectionProxy
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
ActiveSupport.on_load :mongoid do
|
|
43
|
+
include Draper::Decoratable
|
|
40
44
|
end
|
|
41
45
|
end
|
|
42
46
|
|
|
@@ -52,7 +56,12 @@ module Draper
|
|
|
52
56
|
Draper::ViewContext.build
|
|
53
57
|
end
|
|
54
58
|
|
|
55
|
-
console
|
|
59
|
+
console do
|
|
60
|
+
initialize_view_context
|
|
61
|
+
if ActiveSupport.gem_version >= Gem::Version.new('8.1.0')
|
|
62
|
+
ActiveSupport::ExecutionContext.nestable = false
|
|
63
|
+
end
|
|
64
|
+
end
|
|
56
65
|
|
|
57
66
|
runner { initialize_view_context }
|
|
58
67
|
|
data/lib/draper/version.rb
CHANGED
|
@@ -38,17 +38,9 @@ module Draper
|
|
|
38
38
|
def controller
|
|
39
39
|
Draper::ViewContext.controller ||= Draper.default_controller.new
|
|
40
40
|
Draper::ViewContext.controller.tap do |controller|
|
|
41
|
-
controller.request ||=
|
|
41
|
+
controller.request ||= ActionDispatch::TestRequest.create
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
|
-
|
|
45
|
-
def new_test_request(controller)
|
|
46
|
-
is_above_rails_5_1 ? ActionController::TestRequest.create(controller) : ActionController::TestRequest.create
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def is_above_rails_5_1
|
|
50
|
-
ActionController::TestRequest.method(:create).parameters.first == [:req, :controller_class]
|
|
51
|
-
end
|
|
52
44
|
end
|
|
53
45
|
end
|
|
54
46
|
end
|
data/lib/draper.rb
CHANGED
|
@@ -51,12 +51,6 @@ module Draper
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
def self.setup_orm(base)
|
|
55
|
-
base.class_eval do
|
|
56
|
-
include Draper::Decoratable
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
54
|
class UninferrableDecoratorError < NameError
|
|
61
55
|
def initialize(klass)
|
|
62
56
|
super("Could not infer a decorator for #{klass}.")
|