test_data 0.0.1
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 +7 -0
- data/.gitignore +8 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +104 -0
- data/LICENSE.txt +25 -0
- data/README.md +35 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/example/.gitattributes +8 -0
- data/example/.gitignore +24 -0
- data/example/Gemfile +19 -0
- data/example/Gemfile.lock +211 -0
- data/example/README.md +24 -0
- data/example/Rakefile +6 -0
- data/example/app/assets/config/manifest.js +2 -0
- data/example/app/assets/stylesheets/application.css +15 -0
- data/example/app/controllers/application_controller.rb +2 -0
- data/example/app/controllers/boops_controller.rb +10 -0
- data/example/app/helpers/application_helper.rb +2 -0
- data/example/app/models/application_record.rb +3 -0
- data/example/app/models/boop.rb +2 -0
- data/example/app/views/boops/index.html.erb +8 -0
- data/example/app/views/layouts/application.html.erb +15 -0
- data/example/bin/bundle +114 -0
- data/example/bin/rails +4 -0
- data/example/bin/rake +4 -0
- data/example/bin/setup +33 -0
- data/example/config.ru +6 -0
- data/example/config/application.rb +35 -0
- data/example/config/boot.rb +4 -0
- data/example/config/credentials.yml.enc +1 -0
- data/example/config/database.yml +86 -0
- data/example/config/environment.rb +5 -0
- data/example/config/environments/development.rb +60 -0
- data/example/config/environments/production.rb +96 -0
- data/example/config/environments/test.rb +49 -0
- data/example/config/initializers/application_controller_renderer.rb +8 -0
- data/example/config/initializers/backtrace_silencers.rb +8 -0
- data/example/config/initializers/content_security_policy.rb +28 -0
- data/example/config/initializers/cookies_serializer.rb +5 -0
- data/example/config/initializers/filter_parameter_logging.rb +6 -0
- data/example/config/initializers/inflections.rb +16 -0
- data/example/config/initializers/mime_types.rb +4 -0
- data/example/config/initializers/permissions_policy.rb +11 -0
- data/example/config/initializers/wrap_parameters.rb +14 -0
- data/example/config/locales/en.yml +33 -0
- data/example/config/puma.rb +43 -0
- data/example/config/routes.rb +5 -0
- data/example/db/migrate/20210417143158_create_boops.rb +7 -0
- data/example/db/schema.rb +21 -0
- data/example/db/seeds.rb +11 -0
- data/example/public/404.html +67 -0
- data/example/public/422.html +67 -0
- data/example/public/500.html +66 -0
- data/example/public/apple-touch-icon-precomposed.png +0 -0
- data/example/public/apple-touch-icon.png +0 -0
- data/example/public/favicon.ico +0 -0
- data/example/public/robots.txt +1 -0
- data/example/test/application_system_test_case.rb +5 -0
- data/example/test/fixtures/boops.yml +5 -0
- data/example/test/integration/basic_boops_test.rb +18 -0
- data/example/test/integration/migrated_boops_test.rb +7 -0
- data/example/test/integration/parallel_boops_with_fixtures_test.rb +11 -0
- data/example/test/integration/parallel_boops_without_fixtures_test.rb +11 -0
- data/example/test/integration/updated_boops_test.rb +7 -0
- data/example/test/test_helper.rb +41 -0
- data/lib/generators/test_data/database_yaml_generator.rb +24 -0
- data/lib/generators/test_data/environment_file_generator.rb +29 -0
- data/lib/generators/test_data/webpacker_yaml_generator.rb +26 -0
- data/lib/test_data.rb +20 -0
- data/lib/test_data/active_support_ext.rb +9 -0
- data/lib/test_data/config.rb +52 -0
- data/lib/test_data/configuration_verification.rb +3 -0
- data/lib/test_data/configurators.rb +11 -0
- data/lib/test_data/configurators/database_yaml.rb +24 -0
- data/lib/test_data/configurators/environment_file.rb +25 -0
- data/lib/test_data/configurators/webpacker_yaml.rb +38 -0
- data/lib/test_data/detects_database_emptiness.rb +17 -0
- data/lib/test_data/dumps_database.rb +49 -0
- data/lib/test_data/error.rb +4 -0
- data/lib/test_data/installs_configuration.rb +9 -0
- data/lib/test_data/loads_database_dumps.rb +45 -0
- data/lib/test_data/railtie.rb +12 -0
- data/lib/test_data/rake.rb +104 -0
- data/lib/test_data/transactional_data_loader.rb +77 -0
- data/lib/test_data/verifies_configuration.rb +14 -0
- data/lib/test_data/verifies_dumps_are_loadable.rb +37 -0
- data/lib/test_data/version.rb +3 -0
- data/script/test +49 -0
- data/test_data.gemspec +27 -0
- metadata +150 -0
data/example/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
data/example/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
6
|
+
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Example</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<%= csrf_meta_tags %>
|
7
|
+
<%= csp_meta_tag %>
|
8
|
+
|
9
|
+
<%= stylesheet_link_tag 'application', media: 'all' %>
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<%= yield %>
|
14
|
+
</body>
|
15
|
+
</html>
|
data/example/bin/bundle
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/o
|
34
|
+
bundler_version = $1
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/o
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||=
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version
|
67
|
+
end
|
68
|
+
|
69
|
+
def bundler_requirement
|
70
|
+
return "#{Gem::Requirement.default}.a" unless bundler_version
|
71
|
+
|
72
|
+
bundler_gem_version = Gem::Version.new(bundler_version)
|
73
|
+
|
74
|
+
requirement = bundler_gem_version.approximate_recommendation
|
75
|
+
|
76
|
+
return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
|
77
|
+
|
78
|
+
requirement += ".a" if bundler_gem_version.prerelease?
|
79
|
+
|
80
|
+
requirement
|
81
|
+
end
|
82
|
+
|
83
|
+
def load_bundler!
|
84
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
85
|
+
|
86
|
+
activate_bundler
|
87
|
+
end
|
88
|
+
|
89
|
+
def activate_bundler
|
90
|
+
gem_error = activation_error_handling do
|
91
|
+
gem "bundler", bundler_requirement
|
92
|
+
end
|
93
|
+
return if gem_error.nil?
|
94
|
+
require_error = activation_error_handling do
|
95
|
+
require "bundler/version"
|
96
|
+
end
|
97
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
98
|
+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
|
99
|
+
exit 42
|
100
|
+
end
|
101
|
+
|
102
|
+
def activation_error_handling
|
103
|
+
yield
|
104
|
+
nil
|
105
|
+
rescue StandardError, LoadError => e
|
106
|
+
e
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
m.load_bundler!
|
111
|
+
|
112
|
+
if m.invoked_as_script?
|
113
|
+
load Gem.bin_path("bundler", "bundle")
|
114
|
+
end
|
data/example/bin/rails
ADDED
data/example/bin/rake
ADDED
data/example/bin/setup
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
6
|
+
|
7
|
+
def system!(*args)
|
8
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
9
|
+
end
|
10
|
+
|
11
|
+
FileUtils.chdir APP_ROOT do
|
12
|
+
# This script is a way to set up or update your development environment automatically.
|
13
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
14
|
+
# Add necessary setup steps to this file.
|
15
|
+
|
16
|
+
puts "== Installing dependencies =="
|
17
|
+
system! "gem install bundler --conservative"
|
18
|
+
system("bundle check") || system!("bundle install")
|
19
|
+
|
20
|
+
# puts "\n== Copying sample files =="
|
21
|
+
# unless File.exist?('config/database.yml')
|
22
|
+
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
|
23
|
+
# end
|
24
|
+
|
25
|
+
puts "\n== Preparing database =="
|
26
|
+
system! "bin/rails db:prepare"
|
27
|
+
|
28
|
+
puts "\n== Removing old logs and tempfiles =="
|
29
|
+
system! "bin/rails log:clear tmp:clear"
|
30
|
+
|
31
|
+
puts "\n== Restarting application server =="
|
32
|
+
system! "bin/rails restart"
|
33
|
+
end
|
data/example/config.ru
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative "boot"
|
2
|
+
|
3
|
+
require "rails"
|
4
|
+
# Pick the frameworks you want:
|
5
|
+
require "active_model/railtie"
|
6
|
+
# require "active_job/railtie"
|
7
|
+
require "active_record/railtie"
|
8
|
+
# require "active_storage/engine"
|
9
|
+
require "action_controller/railtie"
|
10
|
+
# require "action_mailer/railtie"
|
11
|
+
# require "action_mailbox/engine"
|
12
|
+
# require "action_text/engine"
|
13
|
+
require "action_view/railtie"
|
14
|
+
# require "action_cable/engine"
|
15
|
+
# require "sprockets/railtie"
|
16
|
+
require "rails/test_unit/railtie"
|
17
|
+
|
18
|
+
# Require the gems listed in Gemfile, including any gems
|
19
|
+
# you've limited to :test, :development, or :production.
|
20
|
+
Bundler.require(*Rails.groups)
|
21
|
+
|
22
|
+
module Example
|
23
|
+
class Application < Rails::Application
|
24
|
+
# Initialize configuration defaults for originally generated Rails version.
|
25
|
+
config.load_defaults 6.1
|
26
|
+
|
27
|
+
# Configuration for the application, engines, and railties goes here.
|
28
|
+
#
|
29
|
+
# These settings can be overridden in specific environments using the files
|
30
|
+
# in config/environments, which are processed later.
|
31
|
+
#
|
32
|
+
# config.time_zone = "Central Time (US & Canada)"
|
33
|
+
# config.eager_load_paths << Rails.root.join("extras")
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
F/lkjSeOZwy+4IAYNV/+5sOwn9XOGjyNNvDkNyrpRG0kqoP8jmI4GE8mb73fdRIVoI9H7zefa3GxQ7R+udxqKWMLwAtSgTt+YGf5Eng0IzRBPp7hY2gIxFO0b84/+eG4Q6rD5xsg0kogzK3Ab4jj7f8Ci8vzFclSwqyUwP6TBCnaZJYsLMcNmF3tKBnWrJNKcQJ6Rj6/J2OH/nNi5x+KbsIgbARCJsZEK8PjD+cx8Qs9Cvk99Pj3VljLmjYA0L3jx1uCKahr0tzkkPkujBCKci05QHF/+vq0fcFduxc5wwlf5qMf7wGayz8i1YONyM9yORMrcnvSz/6AKC25np24+nmvZNsuVqtyoA4LRL+k3RBCMKo867FkwJmmGkhZSAFplFdQ2C0qJ+Gzem6UD6Lr70klDaUq1hITDqIc--nPRVkeqxjYlJDoKQ--Iu4hCDiJSpYuKL56Z/CUjA==
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# PostgreSQL. Versions 9.3 and up are supported.
|
2
|
+
#
|
3
|
+
# Install the pg driver:
|
4
|
+
# gem install pg
|
5
|
+
# On macOS with Homebrew:
|
6
|
+
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
|
7
|
+
# On macOS with MacPorts:
|
8
|
+
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
|
9
|
+
# On Windows:
|
10
|
+
# gem install pg
|
11
|
+
# Choose the win32 build.
|
12
|
+
# Install PostgreSQL and put its /bin directory on your path.
|
13
|
+
#
|
14
|
+
# Configure Using Gemfile
|
15
|
+
# gem 'pg'
|
16
|
+
#
|
17
|
+
default: &default
|
18
|
+
adapter: postgresql
|
19
|
+
encoding: unicode
|
20
|
+
# For details on connection pooling, see Rails configuration guide
|
21
|
+
# https://guides.rubyonrails.org/configuring.html#database-pooling
|
22
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
23
|
+
|
24
|
+
development:
|
25
|
+
<<: *default
|
26
|
+
database: example_development
|
27
|
+
|
28
|
+
# The specified database role being used to connect to postgres.
|
29
|
+
# To create additional roles in postgres see `$ createuser --help`.
|
30
|
+
# When left blank, postgres will use the default role. This is
|
31
|
+
# the same name as the operating system user running Rails.
|
32
|
+
#username: example
|
33
|
+
|
34
|
+
# The password associated with the postgres role (username).
|
35
|
+
#password:
|
36
|
+
|
37
|
+
# Connect on a TCP socket. Omitted by default since the client uses a
|
38
|
+
# domain socket that doesn't need configuration. Windows does not have
|
39
|
+
# domain sockets, so uncomment these lines.
|
40
|
+
#host: localhost
|
41
|
+
|
42
|
+
# The TCP port the server listens on. Defaults to 5432.
|
43
|
+
# If your server runs on a different port number, change accordingly.
|
44
|
+
#port: 5432
|
45
|
+
|
46
|
+
# Schema search path. The server defaults to $user,public
|
47
|
+
#schema_search_path: myapp,sharedapp,public
|
48
|
+
|
49
|
+
# Minimum log levels, in increasing order:
|
50
|
+
# debug5, debug4, debug3, debug2, debug1,
|
51
|
+
# log, notice, warning, error, fatal, and panic
|
52
|
+
# Defaults to warning.
|
53
|
+
#min_messages: notice
|
54
|
+
|
55
|
+
# Warning: The database defined as "test" will be erased and
|
56
|
+
# re-generated from your development database when you run "rake".
|
57
|
+
# Do not set this db to the same as development or production.
|
58
|
+
test:
|
59
|
+
<<: *default
|
60
|
+
database: example_test
|
61
|
+
|
62
|
+
# As with config/credentials.yml, you never want to store sensitive information,
|
63
|
+
# like your database password, in your source code. If your source code is
|
64
|
+
# ever seen by anyone, they now have access to your database.
|
65
|
+
#
|
66
|
+
# Instead, provide the password or a full connection URL as an environment
|
67
|
+
# variable when you boot the app. For example:
|
68
|
+
#
|
69
|
+
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
|
70
|
+
#
|
71
|
+
# If the connection URL is provided in the special DATABASE_URL environment
|
72
|
+
# variable, Rails will automatically merge its configuration values on top of
|
73
|
+
# the values provided in this file. Alternatively, you can specify a connection
|
74
|
+
# URL environment variable explicitly:
|
75
|
+
#
|
76
|
+
# production:
|
77
|
+
# url: <%= ENV['MY_APP_DATABASE_URL'] %>
|
78
|
+
#
|
79
|
+
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
|
80
|
+
# for a full overview on how database connection configuration can be specified.
|
81
|
+
#
|
82
|
+
production:
|
83
|
+
<<: *default
|
84
|
+
database: example_production
|
85
|
+
username: example
|
86
|
+
password: <%= ENV['EXAMPLE_DATABASE_PASSWORD'] %>
|
@@ -0,0 +1,60 @@
|
|
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
|
+
# 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
|
8
|
+
# since you don't have to restart the web server when you make code changes.
|
9
|
+
config.cache_classes = false
|
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/disable caching. By default caching is disabled.
|
18
|
+
# Run rails dev:cache to toggle caching.
|
19
|
+
if Rails.root.join("tmp", "caching-dev.txt").exist?
|
20
|
+
config.action_controller.perform_caching = true
|
21
|
+
config.action_controller.enable_fragment_cache_logging = true
|
22
|
+
|
23
|
+
config.cache_store = :memory_store
|
24
|
+
config.public_file_server.headers = {
|
25
|
+
"Cache-Control" => "public, max-age=#{2.days.to_i}"
|
26
|
+
}
|
27
|
+
else
|
28
|
+
config.action_controller.perform_caching = false
|
29
|
+
|
30
|
+
config.cache_store = :null_store
|
31
|
+
end
|
32
|
+
|
33
|
+
# Print deprecation notices to the Rails logger.
|
34
|
+
config.active_support.deprecation = :log
|
35
|
+
|
36
|
+
# Raise exceptions for disallowed deprecations.
|
37
|
+
config.active_support.disallowed_deprecation = :raise
|
38
|
+
|
39
|
+
# Tell Active Support which deprecation messages to disallow.
|
40
|
+
config.active_support.disallowed_deprecation_warnings = []
|
41
|
+
|
42
|
+
# Raise an error on page load if there are pending migrations.
|
43
|
+
config.active_record.migration_error = :page_load
|
44
|
+
|
45
|
+
# Highlight code that triggered database queries in logs.
|
46
|
+
config.active_record.verbose_query_logs = true
|
47
|
+
|
48
|
+
# Raises error for missing translations.
|
49
|
+
# config.i18n.raise_on_missing_translations = true
|
50
|
+
|
51
|
+
# Annotate rendered view with file names.
|
52
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
53
|
+
|
54
|
+
# Use an evented file watcher to asynchronously detect changes in source code,
|
55
|
+
# routes, locales, etc. This feature depends on the listen gem.
|
56
|
+
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
57
|
+
|
58
|
+
# Uncomment if you wish to allow Action Cable access from any origin.
|
59
|
+
# config.action_cable.disable_request_forgery_protection = true
|
60
|
+
end
|