draper 3.0.0 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +55 -0
  3. data/CHANGELOG.md +46 -0
  4. data/Gemfile +11 -2
  5. data/README.md +43 -5
  6. data/bin/bundle +114 -0
  7. data/bin/rake +29 -0
  8. data/draper.gemspec +9 -8
  9. data/lib/draper.rb +3 -0
  10. data/lib/draper/automatic_delegation.rb +4 -2
  11. data/lib/draper/collection_decorator.rb +4 -2
  12. data/lib/draper/compatibility/global_id.rb +22 -0
  13. data/lib/draper/configuration.rb +8 -0
  14. data/lib/draper/decoratable.rb +6 -7
  15. data/lib/draper/decorated_association.rb +0 -2
  16. data/lib/draper/decorator.rb +19 -13
  17. data/lib/draper/delegation.rb +1 -1
  18. data/lib/draper/finders.rb +0 -1
  19. data/lib/draper/helper_proxy.rb +2 -2
  20. data/lib/draper/lazy_helpers.rb +1 -3
  21. data/lib/draper/query_methods.rb +23 -0
  22. data/lib/draper/query_methods/load_strategy.rb +21 -0
  23. data/lib/draper/test_case.rb +3 -3
  24. data/lib/draper/undecorate.rb +1 -1
  25. data/lib/draper/version.rb +1 -1
  26. data/lib/draper/view_context/build_strategy.rb +1 -3
  27. data/lib/draper/view_helpers.rb +5 -5
  28. data/lib/generators/draper/install_generator.rb +1 -1
  29. data/lib/generators/mini_test/decorator_generator.rb +1 -1
  30. data/lib/generators/rails/decorator_generator.rb +1 -1
  31. data/lib/generators/rspec/decorator_generator.rb +6 -4
  32. data/lib/generators/test_unit/decorator_generator.rb +7 -4
  33. data/spec/draper/collection_decorator_spec.rb +5 -6
  34. data/spec/draper/configuration_spec.rb +32 -8
  35. data/spec/draper/decoratable_spec.rb +24 -4
  36. data/spec/draper/decorated_association_spec.rb +0 -2
  37. data/spec/draper/decorator_spec.rb +36 -3
  38. data/spec/draper/draper_spec.rb +1 -0
  39. data/spec/draper/factory_spec.rb +0 -4
  40. data/spec/draper/query_methods/load_strategy_spec.rb +26 -0
  41. data/spec/draper/query_methods_spec.rb +70 -0
  42. data/spec/dummy/app/assets/config/manifest.js +3 -0
  43. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  44. data/spec/dummy/app/jobs/publish_post_job.rb +7 -0
  45. data/spec/dummy/app/models/application_record.rb +3 -0
  46. data/spec/dummy/app/models/post.rb +1 -1
  47. data/spec/dummy/config/application.rb +0 -3
  48. data/spec/dummy/config/environments/development.rb +2 -0
  49. data/spec/dummy/config/environments/production.rb +2 -0
  50. data/spec/dummy/config/environments/test.rb +4 -0
  51. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  52. data/spec/dummy/config/storage.yml +7 -0
  53. data/spec/dummy/db/migrate/20121019115657_create_posts.rb +1 -1
  54. data/spec/dummy/spec/jobs/publish_post_job_spec.rb +9 -0
  55. data/spec/dummy/spec/models/application_spec.rb +7 -0
  56. data/spec/dummy/spec/models/post_spec.rb +11 -2
  57. data/spec/generators/controller/controller_generator_spec.rb +1 -0
  58. data/spec/generators/decorator/decorator_generator_spec.rb +1 -1
  59. data/spec/integration/integration_spec.rb +1 -0
  60. data/spec/spec_helper.rb +9 -0
  61. metadata +72 -20
  62. data/.travis.yml +0 -9
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,7 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
@@ -1,4 +1,4 @@
1
- class CreatePosts < ActiveRecord::Migration
1
+ class CreatePosts < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :posts do |t|
4
4
 
@@ -0,0 +1,9 @@
1
+ RSpec.describe PublishPostJob, type: :job do
2
+ let(:post) { Post.create.decorate }
3
+
4
+ subject(:job) { described_class.perform_later(post) }
5
+
6
+ it 'queues the job' do
7
+ expect { job }.to have_enqueued_job(described_class).with(post.object)
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe ApplicationRecord do
4
+ it { expect(described_class.superclass).to eq ActiveRecord::Base }
5
+
6
+ it { expect(described_class.abstract_class).to be_truthy }
7
+ end
@@ -1,6 +1,15 @@
1
1
  require 'spec_helper'
2
2
  require 'shared_examples/decoratable'
3
3
 
4
- describe Post do
5
- it_behaves_like "a decoratable model"
4
+ RSpec.describe Post do
5
+ it_behaves_like 'a decoratable model'
6
+
7
+ it { should be_a ApplicationRecord }
8
+
9
+ describe '#to_global_id' do
10
+ let(:post) { Post.create }
11
+ subject { post.to_global_id }
12
+
13
+ it { is_expected.to eq post.decorate.to_global_id }
14
+ end
6
15
  end
@@ -3,6 +3,7 @@ require 'dummy/config/environment'
3
3
  require 'ammeter/init'
4
4
  require 'generators/controller_override'
5
5
  require 'generators/rails/decorator_generator'
6
+ SimpleCov.command_name 'test:generator'
6
7
 
7
8
  describe Rails::Generators::ControllerGenerator do
8
9
  destination File.expand_path("../tmp", __FILE__)
@@ -40,7 +40,7 @@ describe Rails::Generators::DecoratorGenerator do
40
40
 
41
41
  context "with an ApplicationDecorator" do
42
42
  before do
43
- allow_any_instance_of(Object).to receive(:require)
43
+ allow_any_instance_of(Object).to receive(:require).and_call_original
44
44
  allow_any_instance_of(Object).to receive(:require).with("application_decorator").and_return(
45
45
  stub_const "ApplicationDecorator", Class.new
46
46
  )
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'support/dummy_app'
3
3
  require 'support/matchers/have_text'
4
+ SimpleCov.command_name 'test:integration'
4
5
 
5
6
  app = DummyApp.new(ENV["RAILS_ENV"])
6
7
  spec_types = {
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,10 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter 'spec'
4
+ add_group 'Draper', 'lib/draper'
5
+ add_group 'Generators', 'lib/generators'
6
+ end
7
+
1
8
  require 'bundler/setup'
2
9
  require 'draper'
3
10
  require 'action_controller'
@@ -16,6 +23,8 @@ class Model; include Draper::Decoratable; end
16
23
  class Product < Model; end
17
24
  class SpecialProduct < Product; end
18
25
  class Other < Model; end
26
+ class Person < Model; end
27
+ class Child < Person; end
19
28
  class ProductDecorator < Draper::Decorator; end
20
29
  class ProductsDecorator < Draper::CollectionDecorator; end
21
30
 
metadata CHANGED
@@ -1,86 +1,100 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: draper
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Casimir
8
8
  - Steve Klabnik
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-08 00:00:00.000000000 Z
12
+ date: 2021-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '5.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '5.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: actionpack
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '5.0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '5.0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: request_store
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '1.0'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '1.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: activemodel
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '5.0'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '5.0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: activemodel-serializers-xml
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - "~>"
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '1.0'
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '1.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: ruby2_keywords
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: ammeter
86
100
  requirement: !ruby/object:Gem::Requirement
@@ -155,14 +169,14 @@ dependencies:
155
169
  name: active_model_serializers
156
170
  requirement: !ruby/object:Gem::Requirement
157
171
  requirements:
158
- - - "~>"
172
+ - - ">="
159
173
  - !ruby/object:Gem::Version
160
174
  version: '0.10'
161
175
  type: :development
162
176
  prerelease: false
163
177
  version_requirements: !ruby/object:Gem::Requirement
164
178
  requirements:
165
- - - "~>"
179
+ - - ">="
166
180
  - !ruby/object:Gem::Version
167
181
  version: '0.10'
168
182
  - !ruby/object:Gem::Dependency
@@ -179,6 +193,20 @@ dependencies:
179
193
  - - ">="
180
194
  - !ruby/object:Gem::Version
181
195
  version: '0'
196
+ - !ruby/object:Gem::Dependency
197
+ name: simplecov
198
+ requirement: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - '='
201
+ - !ruby/object:Gem::Version
202
+ version: 0.17.1
203
+ type: :development
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - '='
208
+ - !ruby/object:Gem::Version
209
+ version: 0.17.1
182
210
  description: Draper adds an object-oriented layer of presentation logic to your Rails
183
211
  apps.
184
212
  email:
@@ -190,10 +218,10 @@ extra_rdoc_files: []
190
218
  files:
191
219
  - ".codeclimate.yml"
192
220
  - ".github/PULL_REQUEST_TEMPLATE.md"
221
+ - ".github/workflows/ci.yml"
193
222
  - ".gitignore"
194
223
  - ".rspec"
195
224
  - ".rubocop.yml"
196
- - ".travis.yml"
197
225
  - ".yardopts"
198
226
  - CHANGELOG.md
199
227
  - CONTRIBUTING.md
@@ -202,11 +230,14 @@ files:
202
230
  - LICENSE
203
231
  - README.md
204
232
  - Rakefile
233
+ - bin/bundle
234
+ - bin/rake
205
235
  - draper.gemspec
206
236
  - lib/draper.rb
207
237
  - lib/draper/automatic_delegation.rb
208
238
  - lib/draper/collection_decorator.rb
209
239
  - lib/draper/compatibility/api_only.rb
240
+ - lib/draper/compatibility/global_id.rb
210
241
  - lib/draper/configuration.rb
211
242
  - lib/draper/decoratable.rb
212
243
  - lib/draper/decoratable/equality.rb
@@ -219,6 +250,8 @@ files:
219
250
  - lib/draper/helper_proxy.rb
220
251
  - lib/draper/helper_support.rb
221
252
  - lib/draper/lazy_helpers.rb
253
+ - lib/draper/query_methods.rb
254
+ - lib/draper/query_methods/load_strategy.rb
222
255
  - lib/draper/railtie.rb
223
256
  - lib/draper/tasks/test.rake
224
257
  - lib/draper/test/devise_helper.rb
@@ -254,6 +287,8 @@ files:
254
287
  - spec/draper/finders_spec.rb
255
288
  - spec/draper/helper_proxy_spec.rb
256
289
  - spec/draper/lazy_helpers_spec.rb
290
+ - spec/draper/query_methods/load_strategy_spec.rb
291
+ - spec/draper/query_methods_spec.rb
257
292
  - spec/draper/undecorate_chain_spec.rb
258
293
  - spec/draper/undecorate_spec.rb
259
294
  - spec/draper/view_context/build_strategy_spec.rb
@@ -261,15 +296,19 @@ files:
261
296
  - spec/draper/view_helpers_spec.rb
262
297
  - spec/dummy/.rspec
263
298
  - spec/dummy/Rakefile
299
+ - spec/dummy/app/assets/config/manifest.js
300
+ - spec/dummy/app/controllers/application_controller.rb
264
301
  - spec/dummy/app/controllers/base_controller.rb
265
302
  - spec/dummy/app/controllers/localized_urls.rb
266
303
  - spec/dummy/app/controllers/posts_controller.rb
267
304
  - spec/dummy/app/decorators/mongoid_post_decorator.rb
268
305
  - spec/dummy/app/decorators/post_decorator.rb
269
306
  - spec/dummy/app/helpers/application_helper.rb
307
+ - spec/dummy/app/jobs/publish_post_job.rb
270
308
  - spec/dummy/app/mailers/application_mailer.rb
271
309
  - spec/dummy/app/mailers/post_mailer.rb
272
310
  - spec/dummy/app/models/admin.rb
311
+ - spec/dummy/app/models/application_record.rb
273
312
  - spec/dummy/app/models/mongoid_post.rb
274
313
  - spec/dummy/app/models/post.rb
275
314
  - spec/dummy/app/models/user.rb
@@ -288,6 +327,7 @@ files:
288
327
  - spec/dummy/config/environments/test.rb
289
328
  - spec/dummy/config/initializers/backtrace_silencers.rb
290
329
  - spec/dummy/config/initializers/draper.rb
330
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
291
331
  - spec/dummy/config/initializers/inflections.rb
292
332
  - spec/dummy/config/initializers/mime_types.rb
293
333
  - spec/dummy/config/initializers/secret_token.rb
@@ -295,6 +335,7 @@ files:
295
335
  - spec/dummy/config/locales/en.yml
296
336
  - spec/dummy/config/mongoid.yml
297
337
  - spec/dummy/config/routes.rb
338
+ - spec/dummy/config/storage.yml
298
339
  - spec/dummy/db/migrate/20121019115657_create_posts.rb
299
340
  - spec/dummy/db/schema.rb
300
341
  - spec/dummy/db/seeds.rb
@@ -312,7 +353,9 @@ files:
312
353
  - spec/dummy/spec/decorators/post_decorator_spec.rb
313
354
  - spec/dummy/spec/decorators/spec_type_spec.rb
314
355
  - spec/dummy/spec/decorators/view_context_spec.rb
356
+ - spec/dummy/spec/jobs/publish_post_job_spec.rb
315
357
  - spec/dummy/spec/mailers/post_mailer_spec.rb
358
+ - spec/dummy/spec/models/application_spec.rb
316
359
  - spec/dummy/spec/models/mongoid_post_spec.rb
317
360
  - spec/dummy/spec/models/post_spec.rb
318
361
  - spec/dummy/spec/shared_examples/decoratable.rb
@@ -343,7 +386,7 @@ homepage: http://github.com/drapergem/draper
343
386
  licenses:
344
387
  - MIT
345
388
  metadata: {}
346
- post_install_message:
389
+ post_install_message:
347
390
  rdoc_options: []
348
391
  require_paths:
349
392
  - lib
@@ -358,9 +401,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
358
401
  - !ruby/object:Gem::Version
359
402
  version: '0'
360
403
  requirements: []
361
- rubyforge_project:
362
- rubygems_version: 2.6.11
363
- signing_key:
404
+ rubygems_version: 3.0.8
405
+ signing_key:
364
406
  specification_version: 4
365
407
  summary: View Models for Rails
366
408
  test_files:
@@ -376,6 +418,8 @@ test_files:
376
418
  - spec/draper/finders_spec.rb
377
419
  - spec/draper/helper_proxy_spec.rb
378
420
  - spec/draper/lazy_helpers_spec.rb
421
+ - spec/draper/query_methods/load_strategy_spec.rb
422
+ - spec/draper/query_methods_spec.rb
379
423
  - spec/draper/undecorate_chain_spec.rb
380
424
  - spec/draper/undecorate_spec.rb
381
425
  - spec/draper/view_context/build_strategy_spec.rb
@@ -383,15 +427,19 @@ test_files:
383
427
  - spec/draper/view_helpers_spec.rb
384
428
  - spec/dummy/.rspec
385
429
  - spec/dummy/Rakefile
430
+ - spec/dummy/app/assets/config/manifest.js
431
+ - spec/dummy/app/controllers/application_controller.rb
386
432
  - spec/dummy/app/controllers/base_controller.rb
387
433
  - spec/dummy/app/controllers/localized_urls.rb
388
434
  - spec/dummy/app/controllers/posts_controller.rb
389
435
  - spec/dummy/app/decorators/mongoid_post_decorator.rb
390
436
  - spec/dummy/app/decorators/post_decorator.rb
391
437
  - spec/dummy/app/helpers/application_helper.rb
438
+ - spec/dummy/app/jobs/publish_post_job.rb
392
439
  - spec/dummy/app/mailers/application_mailer.rb
393
440
  - spec/dummy/app/mailers/post_mailer.rb
394
441
  - spec/dummy/app/models/admin.rb
442
+ - spec/dummy/app/models/application_record.rb
395
443
  - spec/dummy/app/models/mongoid_post.rb
396
444
  - spec/dummy/app/models/post.rb
397
445
  - spec/dummy/app/models/user.rb
@@ -410,6 +458,7 @@ test_files:
410
458
  - spec/dummy/config/environments/test.rb
411
459
  - spec/dummy/config/initializers/backtrace_silencers.rb
412
460
  - spec/dummy/config/initializers/draper.rb
461
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
413
462
  - spec/dummy/config/initializers/inflections.rb
414
463
  - spec/dummy/config/initializers/mime_types.rb
415
464
  - spec/dummy/config/initializers/secret_token.rb
@@ -417,6 +466,7 @@ test_files:
417
466
  - spec/dummy/config/locales/en.yml
418
467
  - spec/dummy/config/mongoid.yml
419
468
  - spec/dummy/config/routes.rb
469
+ - spec/dummy/config/storage.yml
420
470
  - spec/dummy/db/migrate/20121019115657_create_posts.rb
421
471
  - spec/dummy/db/schema.rb
422
472
  - spec/dummy/db/seeds.rb
@@ -434,7 +484,9 @@ test_files:
434
484
  - spec/dummy/spec/decorators/post_decorator_spec.rb
435
485
  - spec/dummy/spec/decorators/spec_type_spec.rb
436
486
  - spec/dummy/spec/decorators/view_context_spec.rb
487
+ - spec/dummy/spec/jobs/publish_post_job_spec.rb
437
488
  - spec/dummy/spec/mailers/post_mailer_spec.rb
489
+ - spec/dummy/spec/models/application_spec.rb
438
490
  - spec/dummy/spec/models/mongoid_post_spec.rb
439
491
  - spec/dummy/spec/models/post_spec.rb
440
492
  - spec/dummy/spec/shared_examples/decoratable.rb
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- language: ruby
2
-
3
- services:
4
- - mongodb
5
-
6
- rvm:
7
- - 2.2.6
8
- - 2.3.3
9
- - 2.4.1