draper 4.0.2 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +41 -25
  3. data/.rspec +1 -2
  4. data/CHANGELOG.md +18 -0
  5. data/Gemfile +27 -5
  6. data/README.md +23 -1
  7. data/draper.gemspec +3 -3
  8. data/lib/draper/automatic_delegation.rb +14 -4
  9. data/lib/draper/decoratable/collection_proxy.rb +15 -0
  10. data/lib/draper/decoratable.rb +2 -2
  11. data/lib/draper/query_methods.rb +1 -1
  12. data/lib/draper/railtie.rb +8 -4
  13. data/lib/draper/version.rb +1 -1
  14. data/lib/draper/view_context/build_strategy.rb +1 -9
  15. data/lib/draper.rb +0 -6
  16. data/spec/draper/decoratable_spec.rb +1 -1
  17. data/spec/draper/decorator_spec.rb +2 -2
  18. data/spec/draper/factory_spec.rb +8 -8
  19. data/spec/draper/query_methods_spec.rb +10 -0
  20. data/spec/draper/view_context/build_strategy_spec.rb +1 -18
  21. data/spec/dummy/.rspec +0 -1
  22. data/spec/dummy/app/decorators/comment_decorator.rb +13 -0
  23. data/spec/dummy/app/decorators/mongoid_post_decorator.rb +1 -3
  24. data/spec/dummy/app/models/admin.rb +2 -4
  25. data/spec/dummy/app/models/comment.rb +3 -0
  26. data/spec/dummy/app/models/mongoid_post.rb +2 -4
  27. data/spec/dummy/app/models/post.rb +4 -0
  28. data/spec/dummy/app/models/user.rb +2 -4
  29. data/spec/dummy/config/application.rb +22 -51
  30. data/spec/dummy/config/environments/development.rb +65 -22
  31. data/spec/dummy/config/environments/production.rb +76 -33
  32. data/spec/dummy/config/environments/test.rb +55 -21
  33. data/spec/dummy/config/initializers/draper.rb +4 -2
  34. data/spec/dummy/db/migrate/20240907041839_create_comments.rb +9 -0
  35. data/spec/dummy/db/schema.rb +16 -9
  36. data/spec/dummy/spec/decorators/active_model_serializers_spec.rb +1 -1
  37. data/spec/dummy/spec/decorators/post_decorator_spec.rb +1 -1
  38. data/spec/dummy/spec/jobs/publish_post_job_spec.rb +2 -0
  39. data/spec/dummy/spec/models/post_spec.rb +41 -5
  40. data/spec/dummy/spec/rails_helper.rb +69 -0
  41. data/spec/dummy/spec/spec_helper.rb +90 -5
  42. data/spec/performance/benchmark.rb +1 -1
  43. data/spec/support/dummy_app.rb +1 -1
  44. metadata +22 -13
@@ -1,8 +1,93 @@
1
- ENV['RAILS_ENV'] ||= 'test'
2
- require File.expand_path('../../config/environment', __FILE__)
3
- require 'rspec/rails'
4
-
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
5
16
  RSpec.configure do |config|
6
- config.expect_with(:rspec) {|c| c.syntax = :expect}
17
+ # rspec-expectations config goes here. You can use an alternate
18
+ # assertion/expectation library such as wrong or the stdlib/minitest
19
+ # assertions if you prefer.
20
+ config.expect_with :rspec do |expectations|
21
+ # This option will default to `true` in RSpec 4. It makes the `description`
22
+ # and `failure_message` of custom matchers include text for helper methods
23
+ # defined using `chain`, e.g.:
24
+ # be_bigger_than(2).and_smaller_than(4).description
25
+ # # => "be bigger than 2 and smaller than 4"
26
+ # ...rather than:
27
+ # # => "be bigger than 2"
28
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29
+ end
30
+
31
+ # rspec-mocks config goes here. You can use an alternate test double
32
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
33
+ config.mock_with :rspec do |mocks|
34
+ # Prevents you from mocking or stubbing a method that does not exist on
35
+ # a real object. This is generally recommended, and will default to
36
+ # `true` in RSpec 4.
37
+ mocks.verify_partial_doubles = true
38
+ end
39
+
40
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41
+ # have no way to turn it off -- the option exists only for backwards
42
+ # compatibility in RSpec 3). It causes shared context metadata to be
43
+ # inherited by the metadata hash of host groups and examples, rather than
44
+ # triggering implicit auto-inclusion in groups with matching metadata.
45
+ config.shared_context_metadata_behavior = :apply_to_host_groups
46
+
47
+ # The settings below are suggested to provide a good initial experience
48
+ # with RSpec, but feel free to customize to your heart's content.
49
+
50
+ # This allows you to limit a spec run to individual examples or groups
51
+ # you care about by tagging them with `:focus` metadata. When nothing
52
+ # is tagged with `:focus`, all examples get run. RSpec also provides
53
+ # aliases for `it`, `describe`, and `context` that include `:focus`
54
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
55
+ config.filter_run_when_matching :focus
56
+
57
+ # Allows RSpec to persist some state between runs in order to support
58
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
59
+ # you configure your source control system to ignore this file.
60
+ config.example_status_persistence_file_path = "spec/examples.txt"
61
+
62
+ # Limits the available syntax to the non-monkey patched syntax that is
63
+ # recommended. For more details, see:
64
+ # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
65
+ # config.disable_monkey_patching!
66
+
67
+ # Many RSpec users commonly either run the entire suite or an individual
68
+ # file, and it's useful to allow more verbose output when running an
69
+ # individual spec file.
70
+ if config.files_to_run.one?
71
+ # Use the documentation formatter for detailed output,
72
+ # unless a formatter has already been configured
73
+ # (e.g. via a command-line flag).
74
+ config.default_formatter = "doc"
75
+ end
76
+
77
+ # Print the 10 slowest examples and example groups at the
78
+ # end of the spec run, to help surface which specs are running
79
+ # particularly slow.
80
+ config.profile_examples = 10
81
+
82
+ # Run specs in random order to surface order dependencies. If you find an
83
+ # order dependency and want to debug it, you can fix the order by providing
84
+ # the seed, which is printed after each run.
85
+ # --seed 1234
7
86
  config.order = :random
87
+
88
+ # Seed global randomization in this process using the `--seed` CLI option.
89
+ # Setting this allows you to use `--seed` to deterministically reproduce
90
+ # test failures related to randomization by passing the same `--seed` value
91
+ # as the one that triggered the failure.
92
+ Kernel.srand config.seed
8
93
  end
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
3
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
4
4
  Bundler.require :default
5
5
 
6
6
  require "benchmark"
@@ -50,7 +50,7 @@ class DummyApp
50
50
  yield
51
51
 
52
52
  Process.kill("KILL", out.pid)
53
- File.delete("tmp/pids/server.pid")
53
+ File.delete("tmp/pids/server.pid") if File.exist?("tmp/pids/server.pid")
54
54
  end
55
55
  end
56
56
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: draper
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Casimir
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-05-27 00:00:00.000000000 Z
12
+ date: 2025-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -138,7 +138,7 @@ dependencies:
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  - !ruby/object:Gem::Dependency
141
- name: minitest-rails
141
+ name: rspec-activerecord-expectations
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - ">="
@@ -152,7 +152,7 @@ dependencies:
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  - !ruby/object:Gem::Dependency
155
- name: capybara
155
+ name: minitest-rails
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - ">="
@@ -166,19 +166,19 @@ dependencies:
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  - !ruby/object:Gem::Dependency
169
- name: active_model_serializers
169
+ name: capybara
170
170
  requirement: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - ">="
173
173
  - !ruby/object:Gem::Version
174
- version: '0.10'
174
+ version: '0'
175
175
  type: :development
176
176
  prerelease: false
177
177
  version_requirements: !ruby/object:Gem::Requirement
178
178
  requirements:
179
179
  - - ">="
180
180
  - !ruby/object:Gem::Version
181
- version: '0.10'
181
+ version: '0'
182
182
  - !ruby/object:Gem::Dependency
183
183
  name: rubocop
184
184
  requirement: !ruby/object:Gem::Requirement
@@ -197,16 +197,16 @@ dependencies:
197
197
  name: simplecov
198
198
  requirement: !ruby/object:Gem::Requirement
199
199
  requirements:
200
- - - '='
200
+ - - ">="
201
201
  - !ruby/object:Gem::Version
202
- version: 0.17.1
202
+ version: '0'
203
203
  type: :development
204
204
  prerelease: false
205
205
  version_requirements: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - '='
207
+ - - ">="
208
208
  - !ruby/object:Gem::Version
209
- version: 0.17.1
209
+ version: '0'
210
210
  description: Draper adds an object-oriented layer of presentation logic to your Rails
211
211
  apps.
212
212
  email:
@@ -240,6 +240,7 @@ files:
240
240
  - lib/draper/compatibility/global_id.rb
241
241
  - lib/draper/configuration.rb
242
242
  - lib/draper/decoratable.rb
243
+ - lib/draper/decoratable/collection_proxy.rb
243
244
  - lib/draper/decoratable/equality.rb
244
245
  - lib/draper/decorated_association.rb
245
246
  - lib/draper/decorates_assigned.rb
@@ -301,6 +302,7 @@ files:
301
302
  - spec/dummy/app/controllers/base_controller.rb
302
303
  - spec/dummy/app/controllers/localized_urls.rb
303
304
  - spec/dummy/app/controllers/posts_controller.rb
305
+ - spec/dummy/app/decorators/comment_decorator.rb
304
306
  - spec/dummy/app/decorators/mongoid_post_decorator.rb
305
307
  - spec/dummy/app/decorators/post_decorator.rb
306
308
  - spec/dummy/app/helpers/application_helper.rb
@@ -309,6 +311,7 @@ files:
309
311
  - spec/dummy/app/mailers/post_mailer.rb
310
312
  - spec/dummy/app/models/admin.rb
311
313
  - spec/dummy/app/models/application_record.rb
314
+ - spec/dummy/app/models/comment.rb
312
315
  - spec/dummy/app/models/mongoid_post.rb
313
316
  - spec/dummy/app/models/post.rb
314
317
  - spec/dummy/app/models/user.rb
@@ -337,6 +340,7 @@ files:
337
340
  - spec/dummy/config/routes.rb
338
341
  - spec/dummy/config/storage.yml
339
342
  - spec/dummy/db/migrate/20121019115657_create_posts.rb
343
+ - spec/dummy/db/migrate/20240907041839_create_comments.rb
340
344
  - spec/dummy/db/schema.rb
341
345
  - spec/dummy/db/seeds.rb
342
346
  - spec/dummy/fast_spec/post_decorator_spec.rb
@@ -358,6 +362,7 @@ files:
358
362
  - spec/dummy/spec/models/application_spec.rb
359
363
  - spec/dummy/spec/models/mongoid_post_spec.rb
360
364
  - spec/dummy/spec/models/post_spec.rb
365
+ - spec/dummy/spec/rails_helper.rb
361
366
  - spec/dummy/spec/shared_examples/decoratable.rb
362
367
  - spec/dummy/spec/spec_helper.rb
363
368
  - spec/dummy/test/decorators/minitest/devise_test.rb
@@ -382,7 +387,7 @@ files:
382
387
  - spec/support/matchers/have_text.rb
383
388
  - spec/support/shared_examples/decoratable_equality.rb
384
389
  - spec/support/shared_examples/view_helpers.rb
385
- homepage: http://github.com/drapergem/draper
390
+ homepage: https://github.com/drapergem/draper
386
391
  licenses:
387
392
  - MIT
388
393
  metadata: {}
@@ -401,7 +406,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
406
  - !ruby/object:Gem::Version
402
407
  version: '0'
403
408
  requirements: []
404
- rubygems_version: 3.0.8
409
+ rubygems_version: 3.5.23
405
410
  signing_key:
406
411
  specification_version: 4
407
412
  summary: View Models for Rails
@@ -432,6 +437,7 @@ test_files:
432
437
  - spec/dummy/app/controllers/base_controller.rb
433
438
  - spec/dummy/app/controllers/localized_urls.rb
434
439
  - spec/dummy/app/controllers/posts_controller.rb
440
+ - spec/dummy/app/decorators/comment_decorator.rb
435
441
  - spec/dummy/app/decorators/mongoid_post_decorator.rb
436
442
  - spec/dummy/app/decorators/post_decorator.rb
437
443
  - spec/dummy/app/helpers/application_helper.rb
@@ -440,6 +446,7 @@ test_files:
440
446
  - spec/dummy/app/mailers/post_mailer.rb
441
447
  - spec/dummy/app/models/admin.rb
442
448
  - spec/dummy/app/models/application_record.rb
449
+ - spec/dummy/app/models/comment.rb
443
450
  - spec/dummy/app/models/mongoid_post.rb
444
451
  - spec/dummy/app/models/post.rb
445
452
  - spec/dummy/app/models/user.rb
@@ -468,6 +475,7 @@ test_files:
468
475
  - spec/dummy/config/routes.rb
469
476
  - spec/dummy/config/storage.yml
470
477
  - spec/dummy/db/migrate/20121019115657_create_posts.rb
478
+ - spec/dummy/db/migrate/20240907041839_create_comments.rb
471
479
  - spec/dummy/db/schema.rb
472
480
  - spec/dummy/db/seeds.rb
473
481
  - spec/dummy/fast_spec/post_decorator_spec.rb
@@ -489,6 +497,7 @@ test_files:
489
497
  - spec/dummy/spec/models/application_spec.rb
490
498
  - spec/dummy/spec/models/mongoid_post_spec.rb
491
499
  - spec/dummy/spec/models/post_spec.rb
500
+ - spec/dummy/spec/rails_helper.rb
492
501
  - spec/dummy/spec/shared_examples/decoratable.rb
493
502
  - spec/dummy/spec/spec_helper.rb
494
503
  - spec/dummy/test/decorators/minitest/devise_test.rb