test_data 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/CHANGELOG.md +2 -0
  4. data/Gemfile +10 -0
  5. data/Gemfile.lock +104 -0
  6. data/LICENSE.txt +25 -0
  7. data/README.md +35 -0
  8. data/Rakefile +11 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/example/.gitattributes +8 -0
  12. data/example/.gitignore +24 -0
  13. data/example/Gemfile +19 -0
  14. data/example/Gemfile.lock +211 -0
  15. data/example/README.md +24 -0
  16. data/example/Rakefile +6 -0
  17. data/example/app/assets/config/manifest.js +2 -0
  18. data/example/app/assets/stylesheets/application.css +15 -0
  19. data/example/app/controllers/application_controller.rb +2 -0
  20. data/example/app/controllers/boops_controller.rb +10 -0
  21. data/example/app/helpers/application_helper.rb +2 -0
  22. data/example/app/models/application_record.rb +3 -0
  23. data/example/app/models/boop.rb +2 -0
  24. data/example/app/views/boops/index.html.erb +8 -0
  25. data/example/app/views/layouts/application.html.erb +15 -0
  26. data/example/bin/bundle +114 -0
  27. data/example/bin/rails +4 -0
  28. data/example/bin/rake +4 -0
  29. data/example/bin/setup +33 -0
  30. data/example/config.ru +6 -0
  31. data/example/config/application.rb +35 -0
  32. data/example/config/boot.rb +4 -0
  33. data/example/config/credentials.yml.enc +1 -0
  34. data/example/config/database.yml +86 -0
  35. data/example/config/environment.rb +5 -0
  36. data/example/config/environments/development.rb +60 -0
  37. data/example/config/environments/production.rb +96 -0
  38. data/example/config/environments/test.rb +49 -0
  39. data/example/config/initializers/application_controller_renderer.rb +8 -0
  40. data/example/config/initializers/backtrace_silencers.rb +8 -0
  41. data/example/config/initializers/content_security_policy.rb +28 -0
  42. data/example/config/initializers/cookies_serializer.rb +5 -0
  43. data/example/config/initializers/filter_parameter_logging.rb +6 -0
  44. data/example/config/initializers/inflections.rb +16 -0
  45. data/example/config/initializers/mime_types.rb +4 -0
  46. data/example/config/initializers/permissions_policy.rb +11 -0
  47. data/example/config/initializers/wrap_parameters.rb +14 -0
  48. data/example/config/locales/en.yml +33 -0
  49. data/example/config/puma.rb +43 -0
  50. data/example/config/routes.rb +5 -0
  51. data/example/db/migrate/20210417143158_create_boops.rb +7 -0
  52. data/example/db/schema.rb +21 -0
  53. data/example/db/seeds.rb +11 -0
  54. data/example/public/404.html +67 -0
  55. data/example/public/422.html +67 -0
  56. data/example/public/500.html +66 -0
  57. data/example/public/apple-touch-icon-precomposed.png +0 -0
  58. data/example/public/apple-touch-icon.png +0 -0
  59. data/example/public/favicon.ico +0 -0
  60. data/example/public/robots.txt +1 -0
  61. data/example/test/application_system_test_case.rb +5 -0
  62. data/example/test/fixtures/boops.yml +5 -0
  63. data/example/test/integration/basic_boops_test.rb +18 -0
  64. data/example/test/integration/migrated_boops_test.rb +7 -0
  65. data/example/test/integration/parallel_boops_with_fixtures_test.rb +11 -0
  66. data/example/test/integration/parallel_boops_without_fixtures_test.rb +11 -0
  67. data/example/test/integration/updated_boops_test.rb +7 -0
  68. data/example/test/test_helper.rb +41 -0
  69. data/lib/generators/test_data/database_yaml_generator.rb +24 -0
  70. data/lib/generators/test_data/environment_file_generator.rb +29 -0
  71. data/lib/generators/test_data/webpacker_yaml_generator.rb +26 -0
  72. data/lib/test_data.rb +20 -0
  73. data/lib/test_data/active_support_ext.rb +9 -0
  74. data/lib/test_data/config.rb +52 -0
  75. data/lib/test_data/configuration_verification.rb +3 -0
  76. data/lib/test_data/configurators.rb +11 -0
  77. data/lib/test_data/configurators/database_yaml.rb +24 -0
  78. data/lib/test_data/configurators/environment_file.rb +25 -0
  79. data/lib/test_data/configurators/webpacker_yaml.rb +38 -0
  80. data/lib/test_data/detects_database_emptiness.rb +17 -0
  81. data/lib/test_data/dumps_database.rb +49 -0
  82. data/lib/test_data/error.rb +4 -0
  83. data/lib/test_data/installs_configuration.rb +9 -0
  84. data/lib/test_data/loads_database_dumps.rb +45 -0
  85. data/lib/test_data/railtie.rb +12 -0
  86. data/lib/test_data/rake.rb +104 -0
  87. data/lib/test_data/transactional_data_loader.rb +77 -0
  88. data/lib/test_data/verifies_configuration.rb +14 -0
  89. data/lib/test_data/verifies_dumps_are_loadable.rb +37 -0
  90. data/lib/test_data/version.rb +3 -0
  91. data/script/test +49 -0
  92. data/test_data.gemspec +27 -0
  93. metadata +150 -0
@@ -0,0 +1,96 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # Code is not reloaded between requests.
7
+ config.cache_classes = true
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.
16
+ config.consider_all_requests_local = false
17
+ config.action_controller.perform_caching = true
18
+
19
+ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
20
+ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
21
+ # config.require_master_key = true
22
+
23
+ # Disable serving static files from the `/public` folder by default since
24
+ # Apache or NGINX already handles this.
25
+ config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
26
+
27
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
28
+ # config.asset_host = 'http://assets.example.com'
29
+
30
+ # Specifies the header that your server uses for sending files.
31
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
32
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
33
+
34
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
35
+ # config.force_ssl = true
36
+
37
+ # Include generic and useful information about system operation, but avoid logging too much
38
+ # information to avoid inadvertent exposure of personally identifiable information (PII).
39
+ config.log_level = :info
40
+
41
+ # Prepend all log lines with the following tags.
42
+ config.log_tags = [:request_id]
43
+
44
+ # Use a different cache store in production.
45
+ # config.cache_store = :mem_cache_store
46
+
47
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
48
+ # the I18n.default_locale when a translation cannot be found).
49
+ config.i18n.fallbacks = true
50
+
51
+ # Send deprecation notices to registered listeners.
52
+ config.active_support.deprecation = :notify
53
+
54
+ # Log disallowed deprecations.
55
+ config.active_support.disallowed_deprecation = :log
56
+
57
+ # Tell Active Support which deprecation messages to disallow.
58
+ config.active_support.disallowed_deprecation_warnings = []
59
+
60
+ # Use default logging formatter so that PID and timestamp are not suppressed.
61
+ config.log_formatter = ::Logger::Formatter.new
62
+
63
+ # Use a different logger for distributed setups.
64
+ # require "syslog/logger"
65
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
66
+
67
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
68
+ logger = ActiveSupport::Logger.new($stdout)
69
+ logger.formatter = config.log_formatter
70
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
71
+ end
72
+
73
+ # Do not dump schema after migrations.
74
+ config.active_record.dump_schema_after_migration = false
75
+
76
+ # Inserts middleware to perform automatic connection switching.
77
+ # The `database_selector` hash is used to pass options to the DatabaseSelector
78
+ # middleware. The `delay` is used to determine how long to wait after a write
79
+ # to send a subsequent read to the primary.
80
+ #
81
+ # The `database_resolver` class is used by the middleware to determine which
82
+ # database is appropriate to use based on the time delay.
83
+ #
84
+ # The `database_resolver_context` class is used by the middleware to set
85
+ # timestamps for the last write to the primary. The resolver uses the context
86
+ # class timestamps to determine how long to wait before reading from the
87
+ # replica.
88
+ #
89
+ # By default Rails will store a last write timestamp in the session. The
90
+ # DatabaseSelector middleware is designed as such you can define your own
91
+ # strategy for connection switching and pass that into the middleware through
92
+ # these configuration options.
93
+ # config.active_record.database_selector = { delay: 2.seconds }
94
+ # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
95
+ # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
96
+ end
@@ -0,0 +1,49 @@
1
+ require "active_support/core_ext/integer/time"
2
+
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!
7
+
8
+ Rails.application.configure do
9
+ # Settings specified here will take precedence over those in config/application.rb.
10
+
11
+ config.cache_classes = true
12
+
13
+ # Do not eager load code on boot. This avoids loading your whole application
14
+ # just for the purpose of running a single test. If you are using a tool that
15
+ # preloads Rails for running tests, you may have to set it to true.
16
+ config.eager_load = false
17
+
18
+ # Configure public file server for tests with Cache-Control for performance.
19
+ config.public_file_server.enabled = true
20
+ config.public_file_server.headers = {
21
+ "Cache-Control" => "public, max-age=#{1.hour.to_i}"
22
+ }
23
+
24
+ # Show full error reports and disable caching.
25
+ config.consider_all_requests_local = true
26
+ config.action_controller.perform_caching = false
27
+ config.cache_store = :null_store
28
+
29
+ # Raise exceptions instead of rendering exception templates.
30
+ config.action_dispatch.show_exceptions = false
31
+
32
+ # Disable request forgery protection in test environment.
33
+ config.action_controller.allow_forgery_protection = false
34
+
35
+ # Print deprecation notices to the stderr.
36
+ config.active_support.deprecation = :stderr
37
+
38
+ # Raise exceptions for disallowed deprecations.
39
+ config.active_support.disallowed_deprecation = :raise
40
+
41
+ # Tell Active Support which deprecation messages to disallow.
42
+ config.active_support.disallowed_deprecation_warnings = []
43
+
44
+ # Raises error for missing translations.
45
+ # config.i18n.raise_on_missing_translations = true
46
+
47
+ # Annotate rendered view with file names.
48
+ # config.action_view.annotate_rendered_view_with_filenames = true
49
+ end
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # ActiveSupport::Reloader.to_prepare do
4
+ # ApplicationController.renderer.defaults.merge!(
5
+ # http_host: 'example.org',
6
+ # https: false
7
+ # )
8
+ # end
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code
7
+ # by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'".
8
+ Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"]
@@ -0,0 +1,28 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Define an application-wide content security policy
4
+ # For further information see the following documentation
5
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
6
+
7
+ # Rails.application.config.content_security_policy do |policy|
8
+ # policy.default_src :self, :https
9
+ # policy.font_src :self, :https, :data
10
+ # policy.img_src :self, :https, :data
11
+ # policy.object_src :none
12
+ # policy.script_src :self, :https
13
+ # policy.style_src :self, :https
14
+
15
+ # # Specify URI for violation reports
16
+ # # policy.report_uri "/csp-violation-report-endpoint"
17
+ # end
18
+
19
+ # If you are using UJS then enable automatic nonce generation
20
+ # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
21
+
22
+ # Set the nonce only to specific directives
23
+ # Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
24
+
25
+ # Report CSP violations to a specified URI
26
+ # For further information see the following documentation:
27
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
28
+ # Rails.application.config.content_security_policy_report_only = true
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Specify a serializer for the signed and encrypted cookie jars.
4
+ # Valid options are :json, :marshal, and :hybrid.
5
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,6 @@
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 += [
5
+ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
6
+ ]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,11 @@
1
+ # Define an application-wide HTTP permissions policy. For further
2
+ # information see https://developers.google.com/web/updates/2018/06/feature-policy
3
+ #
4
+ # Rails.application.config.permissions_policy do |f|
5
+ # f.camera :none
6
+ # f.gyroscope :none
7
+ # f.microphone :none
8
+ # f.usb :none
9
+ # f.fullscreen :self
10
+ # f.payment :self, "https://secure.example.com"
11
+ # end
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,33 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # The following keys must be escaped otherwise they will not be retrieved by
20
+ # the default I18n backend:
21
+ #
22
+ # true, false, on, off, yes, no
23
+ #
24
+ # Instead, surround them with single quotes.
25
+ #
26
+ # en:
27
+ # 'true': 'foo'
28
+ #
29
+ # To learn more, please read the Rails Internationalization guide
30
+ # available at https://guides.rubyonrails.org/i18n.html.
31
+
32
+ en:
33
+ hello: "Hello world"
@@ -0,0 +1,43 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers: a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum; this matches the default thread size of Active Record.
6
+ #
7
+ max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
8
+ min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9
+ threads min_threads_count, max_threads_count
10
+
11
+ # Specifies the `worker_timeout` threshold that Puma will use to wait before
12
+ # terminating a worker in development environments.
13
+ #
14
+ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
15
+
16
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
17
+ #
18
+ port ENV.fetch("PORT", 3000)
19
+
20
+ # Specifies the `environment` that Puma will run in.
21
+ #
22
+ environment ENV.fetch("RAILS_ENV") { "development" }
23
+
24
+ # Specifies the `pidfile` that Puma will use.
25
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26
+
27
+ # Specifies the number of `workers` to boot in clustered mode.
28
+ # Workers are forked web server processes. If using threads and workers together
29
+ # the concurrency of the application would be max `threads` * `workers`.
30
+ # Workers do not work on JRuby or Windows (both of which do not support
31
+ # processes).
32
+ #
33
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
34
+
35
+ # Use the `preload_app!` method when specifying a `workers` number.
36
+ # This directive tells Puma to first boot the application and load code
37
+ # before forking the application. This takes advantage of Copy On Write
38
+ # process behavior so workers use less memory.
39
+ #
40
+ # preload_app!
41
+
42
+ # Allow puma to be restarted by `rails restart` command.
43
+ plugin :tmp_restart
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ resources :boops
3
+
4
+ root "boops#index"
5
+ end
@@ -0,0 +1,7 @@
1
+ class CreateBoops < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :boops do |t|
4
+ t.timestamps
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,21 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 2021_04_17_143158) do
14
+ # These are extensions that must be enabled in order to support this database
15
+ enable_extension "plpgsql"
16
+
17
+ create_table "boops", force: :cascade do |t|
18
+ t.datetime "created_at", precision: 6, null: false
19
+ t.datetime "updated_at", precision: 6, null: false
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7
+ # Character.create(name: 'Luke', movie: movies.first)
8
+
9
+ 10.times do
10
+ Boop.create!
11
+ end
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>