draper 4.0.1 → 4.0.4

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +71 -0
  3. data/.rspec +1 -2
  4. data/CHANGELOG.md +29 -0
  5. data/Gemfile +27 -4
  6. data/README.md +24 -2
  7. data/bin/bundle +114 -0
  8. data/bin/rake +29 -0
  9. data/draper.gemspec +4 -4
  10. data/lib/draper/automatic_delegation.rb +16 -6
  11. data/lib/draper/decoratable/collection_proxy.rb +15 -0
  12. data/lib/draper/decoratable.rb +2 -2
  13. data/lib/draper/helper_proxy.rb +2 -1
  14. data/lib/draper/lazy_helpers.rb +1 -1
  15. data/lib/draper/query_methods.rb +2 -2
  16. data/lib/draper/railtie.rb +8 -4
  17. data/lib/draper/version.rb +1 -1
  18. data/lib/draper/view_context/build_strategy.rb +1 -9
  19. data/lib/draper/view_helpers.rb +1 -1
  20. data/lib/draper.rb +2 -6
  21. data/spec/draper/collection_decorator_spec.rb +5 -4
  22. data/spec/draper/decoratable_spec.rb +1 -1
  23. data/spec/draper/decorator_spec.rb +4 -4
  24. data/spec/draper/factory_spec.rb +8 -8
  25. data/spec/draper/query_methods_spec.rb +10 -0
  26. data/spec/draper/view_context/build_strategy_spec.rb +1 -18
  27. data/spec/dummy/.rspec +0 -1
  28. data/spec/dummy/app/decorators/comment_decorator.rb +13 -0
  29. data/spec/dummy/app/decorators/mongoid_post_decorator.rb +1 -3
  30. data/spec/dummy/app/models/admin.rb +2 -4
  31. data/spec/dummy/app/models/comment.rb +3 -0
  32. data/spec/dummy/app/models/mongoid_post.rb +2 -4
  33. data/spec/dummy/app/models/post.rb +4 -0
  34. data/spec/dummy/app/models/user.rb +2 -4
  35. data/spec/dummy/config/application.rb +22 -51
  36. data/spec/dummy/config/environments/development.rb +66 -21
  37. data/spec/dummy/config/environments/production.rb +77 -32
  38. data/spec/dummy/config/environments/test.rb +56 -20
  39. data/spec/dummy/config/initializers/draper.rb +4 -2
  40. data/spec/dummy/config/storage.yml +7 -0
  41. data/spec/dummy/db/migrate/20240907041839_create_comments.rb +9 -0
  42. data/spec/dummy/db/schema.rb +16 -9
  43. data/spec/dummy/spec/decorators/active_model_serializers_spec.rb +1 -1
  44. data/spec/dummy/spec/decorators/post_decorator_spec.rb +1 -1
  45. data/spec/dummy/spec/jobs/publish_post_job_spec.rb +2 -0
  46. data/spec/dummy/spec/models/post_spec.rb +41 -5
  47. data/spec/dummy/spec/rails_helper.rb +69 -0
  48. data/spec/dummy/spec/spec_helper.rb +90 -5
  49. data/spec/generators/decorator/decorator_generator_spec.rb +1 -1
  50. data/spec/performance/benchmark.rb +1 -1
  51. data/spec/support/dummy_app.rb +1 -1
  52. metadata +40 -13
  53. data/.travis.yml +0 -28
@@ -118,7 +118,7 @@ module Draper
118
118
  it "creates a CollectionDecorator using itself for each item" do
119
119
  object = [Model.new]
120
120
 
121
- expect(CollectionDecorator).to receive(:new).with(object, with: Decorator)
121
+ expect(CollectionDecorator).to receive(:new).with(object, {with: Decorator})
122
122
  Decorator.decorate_collection(object)
123
123
  end
124
124
 
@@ -134,7 +134,7 @@ module Draper
134
134
  it "creates a custom collection decorator using itself for each item" do
135
135
  object = [Model.new]
136
136
 
137
- expect(ProductsDecorator).to receive(:new).with(object, with: ProductDecorator)
137
+ expect(ProductsDecorator).to receive(:new).with(object, {with: ProductDecorator})
138
138
  ProductDecorator.decorate_collection(object)
139
139
  end
140
140
 
@@ -439,7 +439,7 @@ module Draper
439
439
  it "returns a detailed description of the decorator" do
440
440
  decorator = ProductDecorator.new(double)
441
441
 
442
- expect(decorator.inspect).to match /#<ProductDecorator:0x\h+ .+>/
442
+ expect(decorator.inspect).to match(/#<ProductDecorator:0x\h+ .+>/)
443
443
  end
444
444
 
445
445
  it "includes the object" do
@@ -693,7 +693,7 @@ module Draper
693
693
  decorator = decorator_class.new(object)
694
694
 
695
695
  # `print` private method is defined on `Object`
696
- expect{ decorator.print }.not_to raise_error NoMethodError
696
+ expect{ decorator.print }.not_to raise_error
697
697
  end
698
698
  end
699
699
  end
@@ -73,17 +73,17 @@ module Draper
73
73
  worker = ->(*){}
74
74
  allow(Factory::Worker).to receive_messages new: worker
75
75
 
76
- expect(worker).to receive(:call).with(baz: "qux", context: {foo: "bar"})
76
+ expect(worker).to receive(:call).with({baz: "qux", context: {foo: "bar"}})
77
77
  factory.decorate(double, {baz: "qux"})
78
78
  end
79
79
 
80
80
  it "is overridden by explicitly-specified context" do
81
- factory = Factory.new(context: {foo: "bar"})
81
+ factory = Factory.new({context: {foo: "bar"}})
82
82
  worker = ->(*){}
83
83
  allow(Factory::Worker).to receive_messages new: worker
84
84
 
85
- expect(worker).to receive(:call).with(context: {baz: "qux"})
86
- factory.decorate(double, context: {baz: "qux"})
85
+ expect(worker).to receive(:call).with({context: {baz: "qux"}})
86
+ factory.decorate(double, {context: {baz: "qux"}})
87
87
  end
88
88
  end
89
89
  end
@@ -109,7 +109,7 @@ module Draper
109
109
  allow(worker).to receive_messages decorator: decorator
110
110
  context = {foo: "bar"}
111
111
 
112
- expect(decorator).to receive(:call).with(anything(), context: context)
112
+ expect(decorator).to receive(:call).with(anything(), {context: context})
113
113
  worker.call(context: ->{ context })
114
114
  end
115
115
 
@@ -140,7 +140,7 @@ module Draper
140
140
  allow(worker).to receive_messages decorator: decorator
141
141
  context = {foo: "bar"}
142
142
 
143
- expect(decorator).to receive(:call).with(anything(), context: context)
143
+ expect(decorator).to receive(:call).with(anything(), {context: context})
144
144
  worker.call(context: context)
145
145
  end
146
146
  end
@@ -150,7 +150,7 @@ module Draper
150
150
  decorator = ->(*){}
151
151
  allow(worker).to receive_messages decorator: decorator
152
152
 
153
- expect(decorator).to receive(:call).with(anything(), foo: "bar")
153
+ expect(decorator).to receive(:call).with(anything(), {foo: "bar"})
154
154
  worker.call(foo: "bar", context_args: [])
155
155
  end
156
156
  end
@@ -228,7 +228,7 @@ module Draper
228
228
  allow(object).to receive(:decorate){ nil }
229
229
  worker = Factory::Worker.new(nil, object)
230
230
 
231
- expect(decorator_class).to receive(:decorate_collection).with(object, foo: "bar", with: nil).and_return(:decorated)
231
+ expect(decorator_class).to receive(:decorate_collection).with(object, {foo: "bar", with: nil}).and_return(:decorated)
232
232
  expect(worker.decorator.call(object, foo: "bar")).to be :decorated
233
233
  end
234
234
  end
@@ -53,14 +53,24 @@ module Draper
53
53
  context 'when strategy allows collection to call the method' do
54
54
  before do
55
55
  allow(fake_strategy).to receive(:allowed?).with(:some_query_method).and_return(true)
56
+ allow(collection).to receive(:respond_to?).with(:some_query_method).and_return(true)
56
57
  end
57
58
 
58
59
  it { is_expected.to eq(true) }
60
+
61
+ context 'and collection does not implement the method' do
62
+ before do
63
+ allow(collection).to receive(:respond_to?).with(:some_query_method).and_return(false)
64
+ end
65
+
66
+ it { is_expected.to eq(false) }
67
+ end
59
68
  end
60
69
 
61
70
  context 'when strategy does not allow collection to call the method' do
62
71
  before do
63
72
  allow(fake_strategy).to receive(:allowed?).with(:some_query_method).and_return(false)
73
+ allow(collection).to receive(:respond_to?).with(:some_query_method).and_return(true)
64
74
  end
65
75
 
66
76
  it { is_expected.to eq(false) }
@@ -37,7 +37,7 @@ module Draper
37
37
 
38
38
  expect(controller.request).to be_nil
39
39
  strategy.call
40
- expect(controller.request).to be_an ActionController::TestRequest
40
+ expect(controller.request).to be_an ActionDispatch::TestRequest
41
41
  expect(controller.params).to be_empty
42
42
 
43
43
  # sanity checks
@@ -45,23 +45,6 @@ module Draper
45
45
  expect(controller.view_context.params).to be controller.params
46
46
  end
47
47
 
48
- it "compatible with rails 5.1 change on ActionController::TestRequest.create method" do
49
- ActionController::TestRequest.class_eval do
50
- if ActionController::TestRequest.method(:create).parameters.first == []
51
- def create controller_class
52
- create
53
- end
54
- end
55
- end
56
- controller = Class.new(ActionController::Base).new
57
- allow(ViewContext).to receive_messages controller: controller
58
- strategy = ViewContext::BuildStrategy::Full.new
59
-
60
- expect(controller.request).to be_nil
61
- strategy.call
62
- expect(controller.request).to be_an ActionController::TestRequest
63
- end
64
-
65
48
  it "adds methods to the view context from the constructor block" do
66
49
  allow(ViewContext).to receive(:controller).and_return(fake_controller)
67
50
  strategy = ViewContext::BuildStrategy::Full.new do
data/spec/dummy/.rspec CHANGED
@@ -1,2 +1 @@
1
- --color
2
1
  --format progress
@@ -0,0 +1,13 @@
1
+ class CommentDecorator < Draper::Decorator
2
+ delegate_all
3
+
4
+ # Define presentation-specific methods here. Helpers are accessed through
5
+ # `helpers` (aka `h`). You can override attributes, for example:
6
+ #
7
+ # def created_at
8
+ # helpers.content_tag :span, class: 'time' do
9
+ # object.created_at.strftime("%a %m/%d/%y")
10
+ # end
11
+ # end
12
+
13
+ end
@@ -1,4 +1,2 @@
1
- if defined?(Mongoid)
2
- class MongoidPostDecorator < Draper::Decorator
3
- end
1
+ class MongoidPostDecorator < Draper::Decorator
4
2
  end
@@ -1,5 +1,3 @@
1
- if defined?(Devise)
2
- class Admin
3
- extend Devise::Models
4
- end
1
+ class Admin
2
+ extend Devise::Models if defined? Devise
5
3
  end
@@ -0,0 +1,3 @@
1
+ class Comment < ApplicationRecord
2
+ belongs_to :post
3
+ end
@@ -1,5 +1,3 @@
1
- if defined?(Mongoid)
2
- class MongoidPost
3
- include Mongoid::Document
4
- end
1
+ class MongoidPost
2
+ include Mongoid::Document if defined? Mongoid
5
3
  end
@@ -1,3 +1,7 @@
1
1
  class Post < ApplicationRecord
2
2
  # attr_accessible :title, :body
3
+
4
+ has_many :comments
5
+
6
+ broadcasts if defined? Turbo::Broadcastable
3
7
  end
@@ -1,5 +1,3 @@
1
- if defined?(Devise)
2
- class User
3
- extend Devise::Models
4
- end
1
+ class User
2
+ extend Devise::Models if defined? Devise
5
3
  end
@@ -1,63 +1,34 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- def attempt_require(file)
4
- require file
5
- rescue LoadError
6
- end
1
+ require_relative 'boot'
7
2
 
8
3
  require 'rails/all'
9
- require 'draper'
10
- attempt_require 'mongoid'
11
- attempt_require 'devise'
12
- require 'active_model_serializers'
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Kernel.silence_warnings do
8
+ Bundler.require(*Rails.groups)
9
+ end
13
10
 
14
11
  module Dummy
15
12
  class Application < Rails::Application
16
- # Settings in config/environments/* take precedence over those specified here.
17
- # Application configuration should go into files in config/initializers
18
- # -- all .rb files in that directory are automatically loaded.
19
-
20
- # Custom directories with classes and modules you want to be autoloadable.
21
- # config.autoload_paths += %W(#{config.root}/extras)
22
-
23
- # Only load the plugins named here, in the order given (default is alphabetical).
24
- # :all can be used as a placeholder for all plugins not explicitly named.
25
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
26
-
27
- # Activate observers that should always be running.
28
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
29
-
30
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
31
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
32
- # config.time_zone = 'Central Time (US & Canada)'
33
-
34
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
35
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
36
- # config.i18n.default_locale = :de
37
-
38
- # Configure the default encoding used in templates for Ruby 1.9.
39
- config.encoding = "utf-8"
40
-
41
- # Enable escaping HTML in JSON.
42
- config.active_support.escape_html_entities_in_json = true
43
-
44
- # Use SQL instead of Active Record's schema dumper when creating the database.
45
- # This is necessary if your schema can't be completely dumped by the schema dumper,
46
- # like if you have constraints or database-specific column types
47
- # config.active_record.schema_format = :sql
13
+ config.load_defaults Rails::VERSION::STRING.to_f
48
14
 
49
- # Enforce whitelist mode for mass assignment.
50
- # This will create an empty whitelist of attributes available for mass-assignment for all models
51
- # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
52
- # parameters by using an attr_accessible or attr_protected declaration.
53
- # config.active_record.whitelist_attributes = true
15
+ # For compatibility with applications that use this config
16
+ # config.action_controller.include_all_helpers = false # FIXME
54
17
 
55
- # Enable the asset pipeline
56
- # config.assets.enabled = true
18
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
19
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
20
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
21
+ config.try :autoload_lib, ignore: %w[assets tasks] # HACK for Rails below 7
57
22
 
58
- # Version of your assets, change this if you want to expire all your assets
59
- # config.assets.version = '1.0'
23
+ # Configuration for the application, engines, and railties goes here.
24
+ #
25
+ # These settings can be overridden in specific environments using the files
26
+ # in config/environments, which are processed later.
27
+ #
28
+ # config.time_zone = "Central Time (US & Canada)"
29
+ # config.eager_load_paths << Rails.root.join("extras")
60
30
 
31
+ # HACK: allows testing in production & development environments
61
32
  # Tell Action Mailer not to deliver emails to the real world.
62
33
  # The :test delivery method accumulates sent emails in the
63
34
  # ActionMailer::Base.deliveries array.
@@ -1,33 +1,78 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ require "active_support/core_ext/integer/time"
3
2
 
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # In the development environment your application's code is reloaded any time
7
+ # it changes. This slows down response time but is perfect for development
6
8
  # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
9
+ config.enable_reloading = true
10
+
11
+ # Do not eager load code on boot.
12
+ config.eager_load = false
13
+
14
+ # Show full error reports.
15
+ config.consider_all_requests_local = true
16
+
17
+ # Enable server timing.
18
+ config.server_timing = true
19
+
20
+ # Enable/disable caching. By default caching is disabled.
21
+ # Run rails dev:cache to toggle caching.
22
+ if Rails.root.join("tmp/caching-dev.txt").exist?
23
+ config.action_controller.perform_caching = true
24
+ config.action_controller.enable_fragment_cache_logging = true
25
+
26
+ config.cache_store = :memory_store
27
+ config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
28
+ else
29
+ config.action_controller.perform_caching = false
30
+
31
+ config.cache_store = :null_store
32
+ end
8
33
 
9
- # Show full error reports and disable caching
10
- config.consider_all_requests_local = true
11
- config.action_controller.perform_caching = false
34
+ # Store uploaded files on the local file system (see config/storage.yml for options).
35
+ config.active_storage.service = :local
12
36
 
13
- # Print deprecation notices to the Rails logger
37
+ # Don't care if the mailer can't send.
38
+ config.action_mailer.raise_delivery_errors = false
39
+
40
+ # Disable caching for Action Mailer templates even if Action Controller
41
+ # caching is enabled.
42
+ config.action_mailer.perform_caching = false
43
+
44
+ config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
45
+
46
+ # Print deprecation notices to the Rails logger.
14
47
  config.active_support.deprecation = :log
15
48
 
16
- # Only use best-standards-support built into browsers
17
- config.action_dispatch.best_standards_support = :builtin
49
+ # Raise exceptions for disallowed deprecations.
50
+ config.active_support.disallowed_deprecation = :raise
18
51
 
19
- config.eager_load = false
52
+ # Tell Active Support which deprecation messages to disallow.
53
+ config.active_support.disallowed_deprecation_warnings = []
54
+
55
+ # Raise an error on page load if there are pending migrations.
56
+ config.active_record.migration_error = :page_load
57
+
58
+ # Highlight code that triggered database queries in logs.
59
+ config.active_record.verbose_query_logs = true
60
+
61
+ # Highlight code that enqueued background job in logs.
62
+ # config.active_job.verbose_enqueue_logs = true
63
+
64
+ # Suppress logger output for asset requests.
65
+ # config.assets.quiet = true
20
66
 
21
- # Raise exception on mass assignment protection for Active Record models
22
- # config.active_record.mass_assignment_sanitizer = :strict
67
+ # Raises error for missing translations.
68
+ # config.i18n.raise_on_missing_translations = true
23
69
 
24
- # Log the query plan for queries taking more than this (works
25
- # with SQLite, MySQL, and PostgreSQL)
26
- # config.active_record.auto_explain_threshold_in_seconds = 0.5
70
+ # Annotate rendered view with file names.
71
+ # config.action_view.annotate_rendered_view_with_filenames = true
27
72
 
28
- # Do not compress assets
29
- # config.assets.compress = false
73
+ # Uncomment if you wish to allow Action Cable access from any origin.
74
+ # config.action_cable.disable_request_forgery_protection = true
30
75
 
31
- # Expands the lines which load the assets
32
- # config.assets.debug = true
76
+ # Raise error when a before_action's only/except options reference missing actions.
77
+ # config.action_controller.raise_on_missing_callback_actions = true
33
78
  end
@@ -1,57 +1,102 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ require "active_support/core_ext/integer/time"
3
2
 
4
- # Code is not reloaded between requests
5
- config.cache_classes = true
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
6
5
 
7
- # Full error reports are disabled and caching is turned on
6
+ # Code is not reloaded between requests.
7
+ config.enable_reloading = false
8
+
9
+ # Eager load code on boot. This eager loads most of Rails and
10
+ # your application in memory, allowing both threaded web servers
11
+ # and those relying on copy on write to perform better.
12
+ # Rake tasks automatically ignore this option for performance.
13
+ config.eager_load = true
14
+
15
+ # Full error reports are disabled and caching is turned on.
8
16
  config.consider_all_requests_local = false
9
17
  config.action_controller.perform_caching = true
10
18
 
11
- # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
19
+ # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
20
+ # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
21
+ # config.require_master_key = true
13
22
 
14
- config.eager_load = true
23
+ # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
24
+ # config.public_file_server.enabled = false
25
+
26
+ # Compress CSS using a preprocessor.
27
+ # config.assets.css_compressor = :sass
28
+
29
+ # Do not fall back to assets pipeline if a precompiled asset is missed.
30
+ # config.assets.compile = false
15
31
 
16
- # Defaults to nil and saved in location specified by config.assets.prefix
17
- # config.assets.manifest = YOUR_PATH
32
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
33
+ # config.asset_host = "http://assets.example.com"
18
34
 
19
- # Specifies the header that your server uses for sending files
20
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
21
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
35
+ # Specifies the header that your server uses for sending files.
36
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
37
+ # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
38
+
39
+ # Store uploaded files on the local file system (see config/storage.yml for options).
40
+ config.active_storage.service = :local
41
+
42
+ # Mount Action Cable outside main process or domain.
43
+ # config.action_cable.mount_path = nil
44
+ # config.action_cable.url = "wss://example.com/cable"
45
+ # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
46
+
47
+ # Assume all access to the app is happening through a SSL-terminating reverse proxy.
48
+ # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
49
+ # config.assume_ssl = true
22
50
 
23
51
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
24
52
  # config.force_ssl = true
25
53
 
26
- # See everything in the log (default is :info)
27
- # config.log_level = :debug
54
+ # Skip http-to-https redirect for the default health check endpoint.
55
+ # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
28
56
 
29
- # Prepend all log lines with the following tags
30
- # config.log_tags = [ :subdomain, :uuid ]
57
+ # Log to STDOUT by default
58
+ config.logger = ActiveSupport::Logger.new(STDOUT)
59
+ .tap { |logger| logger.formatter = ::Logger::Formatter.new }
60
+ .tap { |logger| break ActiveSupport::TaggedLogging.new logger }
31
61
 
32
- # Use a different logger for distributed setups
33
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
62
+ # Prepend all log lines with the following tags.
63
+ config.log_tags = [:request_id]
34
64
 
35
- # Use a different cache store in production
65
+ # "info" includes generic and useful information about system operation, but avoids logging too much
66
+ # information to avoid inadvertent exposure of personally identifiable information (PII). If you
67
+ # want to log everything, set the level to "debug".
68
+ config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
69
+
70
+ # Use a different cache store in production.
36
71
  # config.cache_store = :mem_cache_store
37
72
 
38
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
39
- # config.action_controller.asset_host = "http://assets.example.com"
73
+ # Use a real queuing backend for Active Job (and separate queues per environment).
74
+ # config.active_job.queue_adapter = :resque
75
+ # config.active_job.queue_name_prefix = "dummy_production"
40
76
 
41
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
42
- # config.assets.precompile += %w( search.js )
77
+ # Disable caching for Action Mailer templates even if Action Controller
78
+ # caching is enabled.
79
+ config.action_mailer.perform_caching = false
43
80
 
44
- # Enable threaded mode
45
- # config.threadsafe!
81
+ # Ignore bad email addresses and do not raise email delivery errors.
82
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
83
+ # config.action_mailer.raise_delivery_errors = false
46
84
 
47
85
  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
48
- # the I18n.default_locale when a translation can not be found)
86
+ # the I18n.default_locale when a translation cannot be found).
49
87
  config.i18n.fallbacks = true
50
88
 
51
- # Send deprecation notices to registered listeners
52
- config.active_support.deprecation = :notify
89
+ # Don't log any deprecations.
90
+ config.active_support.report_deprecations = false
91
+
92
+ # Do not dump schema after migrations.
93
+ config.active_record.dump_schema_after_migration = false
53
94
 
54
- # Log the query plan for queries taking more than this (works
55
- # with SQLite, MySQL, and PostgreSQL)
56
- # config.active_record.auto_explain_threshold_in_seconds = 0.5
95
+ # Enable DNS rebinding protection and other `Host` header attacks.
96
+ # config.hosts = [
97
+ # "example.com", # Allow requests from example.com
98
+ # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
99
+ # ]
100
+ # Skip DNS rebinding protection for the default health check endpoint.
101
+ # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
57
102
  end
@@ -1,33 +1,69 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ require "active_support/core_ext/integer/time"
3
2
 
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
9
7
 
10
- # Configure static asset server for tests with Cache-Control for performance
11
- # config.serve_static_assets = true
12
- # config.static_cache_control = "public, max-age=3600"
8
+ Rails.application.configure do
9
+ # Settings specified here will take precedence over those in config/application.rb.
13
10
 
14
- # Show full error reports and disable caching
11
+ # While tests run files are not watched, reloading is not necessary.
12
+ config.enable_reloading = false
13
+
14
+ # Eager loading loads your entire application. When running a single test locally,
15
+ # this is usually not necessary, and can slow down your test suite. However, it's
16
+ # recommended that you enable it in continuous integration systems to ensure eager
17
+ # loading is working properly before deploying your code.
18
+ config.eager_load = ENV["CI"].present?
19
+
20
+ # Configure public file server for tests with Cache-Control for performance.
21
+ config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
22
+
23
+ # Show full error reports and disable caching.
15
24
  config.consider_all_requests_local = true
16
25
  config.action_controller.perform_caching = false
26
+ config.cache_store = :null_store
27
+
28
+ # Render exception templates for rescuable exceptions and raise for other exceptions.
29
+ config.action_dispatch.show_exceptions = :rescuable
30
+
31
+ # Disable request forgery protection in test environment.
32
+ config.action_controller.allow_forgery_protection = false
17
33
 
18
- # Raise exceptions instead of rendering exception templates
19
- config.action_dispatch.show_exceptions = false
34
+ # Store uploaded files on the local file system in a temporary directory.
35
+ config.active_storage.service = :test
20
36
 
21
- # Disable request forgery protection in test environment
22
- config.action_controller.allow_forgery_protection = false
37
+ config.active_job.queue_adapter = :test # TODO: remove alongside support for Rails below 7.2
23
38
 
24
- # Raise exception on mass assignment protection for Active Record models
25
- # config.active_record.mass_assignment_sanitizer = :strict
39
+ # Disable caching for Action Mailer templates even if Action Controller
40
+ # caching is enabled.
41
+ config.action_mailer.perform_caching = false
26
42
 
27
- # Print deprecation notices to the stderr
43
+ # Tell Action Mailer not to deliver emails to the real world.
44
+ # The :test delivery method accumulates sent emails in the
45
+ # ActionMailer::Base.deliveries array.
46
+ config.action_mailer.delivery_method = :test
47
+
48
+ # Unlike controllers, the mailer instance doesn't have any context about the
49
+ # incoming request so you'll need to provide the :host parameter yourself.
50
+ config.action_mailer.default_url_options = { host: "www.example.com" }
51
+
52
+ # Print deprecation notices to the stderr.
28
53
  config.active_support.deprecation = :stderr
29
54
 
30
- config.eager_load = false
55
+ # Raise exceptions for disallowed deprecations.
56
+ config.active_support.disallowed_deprecation = :raise
57
+
58
+ # Tell Active Support which deprecation messages to disallow.
59
+ config.active_support.disallowed_deprecation_warnings = []
60
+
61
+ # Raises error for missing translations.
62
+ # config.i18n.raise_on_missing_translations = true
63
+
64
+ # Annotate rendered view with file names.
65
+ # config.action_view.annotate_rendered_view_with_filenames = true
31
66
 
32
- config.active_job.queue_adapter = :test
67
+ # Raise error when a before_action's only/except options reference missing actions.
68
+ # config.action_controller.raise_on_missing_callback_actions = true
33
69
  end
@@ -1,3 +1,5 @@
1
- Draper.configure do |config|
2
- config.default_controller = BaseController
1
+ Rails.application.config.to_prepare do
2
+ Draper.configure do |config|
3
+ config.default_controller = BaseController
4
+ end
3
5
  end