railties 7.0.8 → 7.2.0
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 +4 -4
- data/CHANGELOG.md +188 -268
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.md +99 -0
- data/README.rdoc +4 -4
- data/lib/minitest/rails_plugin.rb +67 -1
- data/lib/rails/all.rb +1 -3
- data/lib/rails/api/task.rb +39 -6
- data/lib/rails/application/bootstrap.rb +28 -10
- data/lib/rails/application/configuration.rb +228 -72
- data/lib/rails/application/default_middleware_stack.rb +8 -2
- data/lib/rails/application/dummy_config.rb +19 -0
- data/lib/rails/application/finisher.rb +50 -33
- data/lib/rails/application.rb +110 -76
- data/lib/rails/backtrace_cleaner.rb +19 -4
- data/lib/rails/cli.rb +5 -3
- data/lib/rails/command/actions.rb +10 -12
- data/lib/rails/command/base.rb +55 -53
- data/lib/rails/command/environment_argument.rb +32 -16
- data/lib/rails/command/helpers/editor.rb +17 -12
- data/lib/rails/command.rb +84 -33
- data/lib/rails/commands/about/about_command.rb +14 -0
- data/lib/rails/commands/app/update_command.rb +93 -0
- data/lib/rails/commands/application/application_command.rb +2 -0
- data/lib/rails/commands/boot/boot_command.rb +14 -0
- data/lib/rails/commands/console/console_command.rb +11 -30
- data/lib/rails/commands/console/irb_console.rb +137 -0
- data/lib/rails/commands/credentials/USAGE +53 -55
- data/lib/rails/commands/credentials/credentials_command/diffing.rb +5 -3
- data/lib/rails/commands/credentials/credentials_command.rb +64 -70
- data/lib/rails/commands/db/system/change/change_command.rb +2 -1
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +32 -131
- data/lib/rails/commands/destroy/destroy_command.rb +3 -2
- data/lib/rails/commands/dev/dev_command.rb +1 -6
- data/lib/rails/commands/devcontainer/devcontainer_command.rb +39 -0
- data/lib/rails/commands/encrypted/USAGE +15 -20
- data/lib/rails/commands/encrypted/encrypted_command.rb +46 -35
- data/lib/rails/commands/gem_help/USAGE +16 -0
- data/lib/rails/commands/gem_help/gem_help_command.rb +13 -0
- data/lib/rails/commands/generate/generate_command.rb +2 -2
- data/lib/rails/commands/help/USAGE +13 -13
- data/lib/rails/commands/help/help_command.rb +21 -2
- data/lib/rails/commands/initializers/initializers_command.rb +1 -4
- data/lib/rails/commands/middleware/middleware_command.rb +17 -0
- data/lib/rails/commands/new/new_command.rb +2 -0
- data/lib/rails/commands/notes/notes_command.rb +2 -1
- data/lib/rails/commands/plugin/plugin_command.rb +2 -0
- data/lib/rails/commands/rake/rake_command.rb +25 -22
- data/lib/rails/commands/restart/restart_command.rb +14 -0
- data/lib/rails/commands/routes/routes_command.rb +13 -1
- data/lib/rails/commands/runner/USAGE +14 -12
- data/lib/rails/commands/runner/runner_command.rb +42 -19
- data/lib/rails/commands/secret/secret_command.rb +13 -0
- data/lib/rails/commands/server/server_command.rb +37 -34
- data/lib/rails/commands/test/USAGE +14 -0
- data/lib/rails/commands/test/test_command.rb +58 -14
- data/lib/rails/commands/unused_routes/unused_routes_command.rb +75 -0
- data/lib/rails/commands/version/version_command.rb +1 -0
- data/lib/rails/configuration.rb +15 -6
- data/lib/rails/console/app.rb +5 -35
- data/lib/rails/console/helpers.rb +5 -16
- data/lib/rails/console/methods.rb +23 -0
- data/lib/rails/deprecator.rb +7 -0
- data/lib/rails/engine/configuration.rb +50 -6
- data/lib/rails/engine.rb +51 -23
- data/lib/rails/gem_version.rb +3 -3
- data/lib/rails/generators/actions.rb +6 -15
- data/lib/rails/generators/active_model.rb +28 -14
- data/lib/rails/generators/app_base.rb +382 -88
- data/lib/rails/generators/app_name.rb +3 -14
- data/lib/rails/generators/base.rb +21 -9
- data/lib/rails/generators/database.rb +231 -35
- data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +1 -1
- data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +2 -0
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +2 -0
- data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +2 -0
- data/lib/rails/generators/generated_attribute.rb +38 -1
- data/lib/rails/generators/migration.rb +4 -5
- data/lib/rails/generators/model_helpers.rb +2 -1
- data/lib/rails/generators/rails/app/USAGE +22 -6
- data/lib/rails/generators/rails/app/app_generator.rb +132 -82
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +110 -0
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +19 -21
- data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +4 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +8 -1
- data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/views/pwa/manifest.json.erb.tt +22 -0
- data/lib/rails/generators/rails/app/templates/app/views/pwa/service-worker.js +26 -0
- data/lib/rails/generators/rails/app/templates/bin/brakeman.tt +6 -0
- data/lib/rails/generators/rails/app/templates/bin/rubocop.tt +7 -0
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +15 -2
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +6 -17
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +11 -6
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +10 -3
- data/lib/rails/generators/rails/app/templates/config/databases/{jdbcmysql.yml.tt → trilogy.yml.tt} +12 -7
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +25 -8
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +37 -28
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +20 -13
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +2 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_2.rb.tt +70 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +11 -9
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +11 -13
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +24 -34
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +9 -1
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +6 -4
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +15 -0
- data/lib/rails/generators/rails/app/templates/dockerignore.tt +56 -0
- data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +138 -0
- data/lib/rails/generators/rails/app/templates/github/dependabot.yml +12 -0
- data/lib/rails/generators/rails/app/templates/gitignore.tt +7 -11
- data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
- data/lib/rails/generators/rails/app/templates/public/406-unsupported-browser.html +66 -0
- data/lib/rails/generators/rails/app/templates/public/icon.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/icon.svg +3 -0
- data/lib/rails/generators/rails/app/templates/rubocop.yml.tt +8 -0
- data/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +10 -8
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +9 -7
- data/lib/rails/generators/rails/application_record/application_record_generator.rb +4 -0
- data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +2 -1
- data/lib/rails/generators/rails/controller/USAGE +12 -4
- data/lib/rails/generators/rails/controller/controller_generator.rb +6 -1
- data/lib/rails/generators/rails/controller/templates/controller.rb.tt +1 -1
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +29 -24
- data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +8 -0
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +146 -5
- data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +166 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +3 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/compose.yaml.tt +47 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/devcontainer.json.tt +37 -0
- data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +1 -2
- data/lib/rails/generators/rails/migration/USAGE +21 -11
- data/lib/rails/generators/rails/migration/migration_generator.rb +4 -0
- data/lib/rails/generators/rails/model/model_generator.rb +4 -0
- data/lib/rails/generators/rails/plugin/USAGE +17 -6
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +43 -22
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +7 -3
- data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +2 -0
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -17
- data/lib/rails/generators/rails/plugin/templates/bin/rubocop.tt +7 -0
- data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +103 -0
- data/lib/rails/generators/rails/plugin/templates/github/dependabot.yml +12 -0
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +0 -2
- data/lib/rails/generators/rails/plugin/templates/rubocop.yml.tt +8 -0
- data/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +4 -4
- data/lib/rails/generators/rails/resource/resource_generator.rb +6 -0
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -1
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +1 -1
- data/lib/rails/generators/test_case.rb +2 -2
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +6 -4
- data/lib/rails/generators/test_unit/mailer/templates/preview.rb.tt +3 -2
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +16 -2
- data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +2 -2
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +2 -2
- data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +2 -0
- data/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb.tt +1 -1
- data/lib/rails/generators/testing/assertions.rb +20 -0
- data/lib/rails/generators/testing/{behaviour.rb → behavior.rb} +8 -4
- data/lib/rails/generators.rb +7 -15
- data/lib/rails/health_controller.rb +55 -0
- data/lib/rails/info.rb +3 -3
- data/lib/rails/info_controller.rb +31 -11
- data/lib/rails/mailers_controller.rb +29 -6
- data/lib/rails/paths.rb +15 -12
- data/lib/rails/pwa_controller.rb +15 -0
- data/lib/rails/rack/logger.rb +27 -16
- data/lib/rails/rackup/server.rb +15 -0
- data/lib/rails/railtie/configurable.rb +2 -2
- data/lib/rails/railtie/configuration.rb +14 -1
- data/lib/rails/railtie.rb +20 -21
- data/lib/rails/source_annotation_extractor.rb +67 -18
- data/lib/rails/tasks/engine.rake +8 -8
- data/lib/rails/tasks/framework.rake +2 -34
- data/lib/rails/tasks/log.rake +1 -1
- data/lib/rails/tasks/misc.rake +3 -14
- data/lib/rails/tasks/statistics.rake +5 -4
- data/lib/rails/tasks/tmp.rake +6 -6
- data/lib/rails/tasks/zeitwerk.rake +15 -35
- data/lib/rails/tasks.rb +0 -2
- data/lib/rails/templates/layouts/application.html.erb +1 -1
- data/lib/rails/templates/rails/mailers/email.html.erb +44 -8
- data/lib/rails/templates/rails/mailers/index.html.erb +14 -7
- data/lib/rails/templates/rails/mailers/mailer.html.erb +11 -5
- data/lib/rails/templates/rails/welcome/index.html.erb +5 -2
- data/lib/rails/test_help.rb +11 -18
- data/lib/rails/test_unit/line_filtering.rb +1 -1
- data/lib/rails/test_unit/reporter.rb +14 -4
- data/lib/rails/test_unit/runner.rb +62 -20
- data/lib/rails/test_unit/test_parser.rb +133 -0
- data/lib/rails/test_unit/testing.rake +13 -33
- data/lib/rails/testing/maintain_test_schema.rb +16 -0
- data/lib/rails/version.rb +1 -1
- data/lib/rails/zeitwerk_checker.rb +15 -0
- data/lib/rails.rb +20 -17
- metadata +89 -42
- data/RDOC_MAIN.rdoc +0 -97
- data/lib/rails/app_updater.rb +0 -40
- data/lib/rails/application/dummy_erb_compiler.rb +0 -18
- data/lib/rails/commands/secrets/USAGE +0 -66
- data/lib/rails/commands/secrets/secrets_command.rb +0 -65
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +0 -68
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +0 -70
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +0 -24
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +0 -62
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +0 -53
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_0.rb.tt +0 -143
- data/lib/rails/generators/rails/app/templates/public/apple-touch-icon-precomposed.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/apple-touch-icon.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/favicon.ico +0 -0
- data/lib/rails/generators/rails/model/USAGE +0 -113
- data/lib/rails/ruby_version_check.rb +0 -15
- data/lib/rails/secrets.rb +0 -110
- data/lib/rails/tasks/middleware.rake +0 -9
- data/lib/rails/tasks/restart.rake +0 -9
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "ripper"
|
4
|
+
|
3
5
|
module Rails
|
4
|
-
# Implements the logic behind
|
6
|
+
# Implements the logic behind +Rails::Command::NotesCommand+. See <tt>rails notes --help</tt> for usage information.
|
5
7
|
#
|
6
8
|
# Annotation objects are triplets <tt>:line</tt>, <tt>:tag</tt>, <tt>:text</tt> that
|
7
9
|
# represent the line where the annotation lives, its tag, and its text. Note
|
@@ -11,6 +13,44 @@ module Rails
|
|
11
13
|
# start with the tag optionally followed by a colon. Everything up to the end
|
12
14
|
# of the line (or closing ERB comment tag) is considered to be their text.
|
13
15
|
class SourceAnnotationExtractor
|
16
|
+
# Wraps a regular expression that will be tested against each of the source
|
17
|
+
# file's comments.
|
18
|
+
class ParserExtractor < Struct.new(:pattern)
|
19
|
+
class Parser < Ripper
|
20
|
+
attr_reader :comments, :pattern
|
21
|
+
|
22
|
+
def initialize(source, pattern:)
|
23
|
+
super(source)
|
24
|
+
@pattern = pattern
|
25
|
+
@comments = []
|
26
|
+
end
|
27
|
+
|
28
|
+
def on_comment(value)
|
29
|
+
@comments << Annotation.new(lineno, $1, $2) if value =~ pattern
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def annotations(file)
|
34
|
+
contents = File.read(file, encoding: Encoding::BINARY)
|
35
|
+
parser = Parser.new(contents, pattern: pattern).tap(&:parse)
|
36
|
+
parser.error? ? [] : parser.comments
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Wraps a regular expression that will iterate through a file's lines and
|
41
|
+
# test each one for the given pattern.
|
42
|
+
class PatternExtractor < Struct.new(:pattern)
|
43
|
+
def annotations(file)
|
44
|
+
lineno = 0
|
45
|
+
|
46
|
+
File.readlines(file, encoding: Encoding::BINARY).inject([]) do |list, line|
|
47
|
+
lineno += 1
|
48
|
+
next list unless line =~ pattern
|
49
|
+
list << Annotation.new(lineno, $1, $2)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
14
54
|
class Annotation < Struct.new(:line, :tag, :text)
|
15
55
|
def self.directories
|
16
56
|
@@directories ||= %w(app config db lib test)
|
@@ -42,9 +82,21 @@ module Rails
|
|
42
82
|
extensions[/\.(#{exts.join("|")})$/] = block
|
43
83
|
end
|
44
84
|
|
45
|
-
register_extensions("builder", "rb", "rake", "
|
46
|
-
|
47
|
-
|
85
|
+
register_extensions("builder", "rb", "rake", "ruby") do |tag|
|
86
|
+
ParserExtractor.new(/#\s*(#{tag}):?\s*(.*)$/)
|
87
|
+
end
|
88
|
+
|
89
|
+
register_extensions("yml", "yaml") do |tag|
|
90
|
+
PatternExtractor.new(/#\s*(#{tag}):?\s*(.*)$/)
|
91
|
+
end
|
92
|
+
|
93
|
+
register_extensions("css", "js") do |tag|
|
94
|
+
PatternExtractor.new(/\/\/\s*(#{tag}):?\s*(.*)$/)
|
95
|
+
end
|
96
|
+
|
97
|
+
register_extensions("erb") do |tag|
|
98
|
+
PatternExtractor.new(/<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/)
|
99
|
+
end
|
48
100
|
|
49
101
|
# Returns a representation of the annotation that looks like this:
|
50
102
|
#
|
@@ -111,7 +163,17 @@ module Rails
|
|
111
163
|
|
112
164
|
if extension
|
113
165
|
pattern = extension.last.call(tag)
|
114
|
-
|
166
|
+
|
167
|
+
# In case a user-defined pattern returns nothing for the given set
|
168
|
+
# of tags, we exit early.
|
169
|
+
next unless pattern
|
170
|
+
|
171
|
+
# If a user-defined pattern returns a regular expression, we will
|
172
|
+
# wrap it in a PatternExtractor to keep the same API.
|
173
|
+
pattern = PatternExtractor.new(pattern) if pattern.is_a?(Regexp)
|
174
|
+
|
175
|
+
annotations = pattern.annotations(item)
|
176
|
+
results.update(item => annotations) if annotations.any?
|
115
177
|
end
|
116
178
|
end
|
117
179
|
end
|
@@ -119,19 +181,6 @@ module Rails
|
|
119
181
|
results
|
120
182
|
end
|
121
183
|
|
122
|
-
# If +file+ is the filename of a file that contains annotations this method returns
|
123
|
-
# a hash with a single entry that maps +file+ to an array of its annotations.
|
124
|
-
# Otherwise it returns an empty hash.
|
125
|
-
def extract_annotations_from(file, pattern)
|
126
|
-
lineno = 0
|
127
|
-
result = File.readlines(file, encoding: Encoding::BINARY).inject([]) do |list, line|
|
128
|
-
lineno += 1
|
129
|
-
next list unless line =~ pattern
|
130
|
-
list << Annotation.new(lineno, $1, $2)
|
131
|
-
end
|
132
|
-
result.empty? ? {} : { file => result }
|
133
|
-
end
|
134
|
-
|
135
184
|
# Prints the mapping from filenames to annotations in +results+ ordered by filename.
|
136
185
|
# The +options+ hash is passed to each annotation's +to_s+.
|
137
186
|
def display(results, options = {})
|
data/lib/rails/tasks/engine.rake
CHANGED
@@ -18,7 +18,7 @@ task "load_app" do
|
|
18
18
|
task environment: "app:environment"
|
19
19
|
|
20
20
|
if !defined?(ENGINE_ROOT) || !ENGINE_ROOT
|
21
|
-
ENGINE_ROOT = find_engine_path(APP_RAKEFILE)
|
21
|
+
ENGINE_ROOT = find_engine_path(Pathname.new(APP_RAKEFILE))
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -43,17 +43,17 @@ namespace :db do
|
|
43
43
|
app_task "create"
|
44
44
|
app_task "create:all"
|
45
45
|
|
46
|
-
desc "
|
46
|
+
desc "Drop the database for the current Rails.env (use db:drop:all to drop all databases)"
|
47
47
|
app_task "drop"
|
48
48
|
app_task "drop:all"
|
49
49
|
|
50
50
|
desc "Load fixtures into the current environment's database."
|
51
51
|
app_task "fixtures:load"
|
52
52
|
|
53
|
-
desc "
|
53
|
+
desc "Roll the schema back to the previous version (specify steps w/ STEP=n)."
|
54
54
|
app_task "rollback"
|
55
55
|
|
56
|
-
desc "
|
56
|
+
desc "Create a database schema file (either db/schema.rb or db/structure.sql, depending on `config.active_record.schema_format`)"
|
57
57
|
app_task "schema:dump"
|
58
58
|
|
59
59
|
desc "Load a schema.rb file into the database"
|
@@ -65,7 +65,7 @@ namespace :db do
|
|
65
65
|
desc "Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the database first)"
|
66
66
|
app_task "setup"
|
67
67
|
|
68
|
-
desc "
|
68
|
+
desc "Retrieve the current schema version number"
|
69
69
|
app_task "version"
|
70
70
|
|
71
71
|
# desc 'Load the test schema'
|
@@ -73,12 +73,12 @@ namespace :db do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def find_engine_path(path)
|
76
|
-
return File.expand_path(Dir.pwd) if path
|
76
|
+
return File.expand_path(Dir.pwd) if path.root?
|
77
77
|
|
78
78
|
if Rails::Engine.find(path)
|
79
|
-
path
|
79
|
+
path.to_s
|
80
80
|
else
|
81
|
-
find_engine_path(
|
81
|
+
find_engine_path(path.join(".."))
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -1,18 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
namespace :app do
|
4
|
-
desc "
|
5
|
-
task update: [ "update:configs", "update:bin", "update:db", "update:active_storage", "update:upgrade_guide_info" ]
|
6
|
-
|
7
|
-
desc "Applies the template supplied by LOCATION=(/path/to/template) or URL"
|
4
|
+
desc "Apply the template supplied by LOCATION=(/path/to/template) or URL"
|
8
5
|
task template: :environment do
|
9
6
|
template = ENV["LOCATION"]
|
10
7
|
raise "No LOCATION value given. Please set LOCATION either as path to a file or a URL" if template.blank?
|
11
|
-
template = File.expand_path(template) unless %r{\A[A-Za-z][A-Za-z0-9+\-.]*://}.match?(template)
|
12
8
|
require "rails/generators"
|
13
9
|
require "rails/generators/rails/app/app_generator"
|
14
|
-
|
15
|
-
generator.apply template, verbose: false
|
10
|
+
Rails::Generators::AppGenerator.apply_rails_template(template, Rails.root)
|
16
11
|
end
|
17
12
|
|
18
13
|
namespace :templates do
|
@@ -36,31 +31,4 @@ namespace :app do
|
|
36
31
|
end
|
37
32
|
end
|
38
33
|
end
|
39
|
-
|
40
|
-
namespace :update do
|
41
|
-
require "rails/app_updater"
|
42
|
-
|
43
|
-
# desc "Update config files from your current rails install"
|
44
|
-
task :configs do
|
45
|
-
Rails::AppUpdater.invoke_from_app_generator :create_boot_file
|
46
|
-
Rails::AppUpdater.invoke_from_app_generator :update_config_files
|
47
|
-
end
|
48
|
-
|
49
|
-
# desc "Adds new executables to the application bin/ directory"
|
50
|
-
task :bin do
|
51
|
-
Rails::AppUpdater.invoke_from_app_generator :update_bin_files
|
52
|
-
end
|
53
|
-
|
54
|
-
task :db do
|
55
|
-
Rails::AppUpdater.invoke_from_app_generator :update_db_schema
|
56
|
-
end
|
57
|
-
|
58
|
-
task :active_storage do
|
59
|
-
Rails::AppUpdater.invoke_from_app_generator :update_active_storage
|
60
|
-
end
|
61
|
-
|
62
|
-
task :upgrade_guide_info do
|
63
|
-
Rails::AppUpdater.invoke_from_app_generator :display_upgrade_guide_info
|
64
|
-
end
|
65
|
-
end
|
66
34
|
end
|
data/lib/rails/tasks/log.rake
CHANGED
@@ -7,7 +7,7 @@ namespace :log do
|
|
7
7
|
# - defaults to all environments log files i.e. 'development,test,production'
|
8
8
|
# - ENV['LOGS']=all truncates all files i.e. log/*.log
|
9
9
|
# - ENV['LOGS']='test,development' truncates only specified files
|
10
|
-
desc "
|
10
|
+
desc "Truncate all/specified *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)"
|
11
11
|
task :clear do
|
12
12
|
log_files.each do |file|
|
13
13
|
clear_log_file(file)
|
data/lib/rails/tasks/misc.rake
CHANGED
@@ -1,16 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
desc "Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)."
|
4
|
-
task :secret do
|
5
|
-
require "securerandom"
|
6
|
-
puts SecureRandom.hex(64)
|
7
|
-
end
|
8
|
-
|
9
|
-
desc "List versions of all Rails frameworks and the environment"
|
10
|
-
task about: :environment do
|
11
|
-
puts Rails::Info
|
12
|
-
end
|
13
|
-
|
14
3
|
namespace :time do
|
15
4
|
desc "List all time zones, list by two-letter country code (`bin/rails time:zones[US]`), or list by UTC offset (`bin/rails time:zones[-8]`)"
|
16
5
|
task :zones, :country_or_offset do |t, args|
|
@@ -28,17 +17,17 @@ namespace :time do
|
|
28
17
|
end
|
29
18
|
|
30
19
|
namespace :zones do
|
31
|
-
# desc '
|
20
|
+
# desc 'Display all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter, e.g., OFFSET=-6'
|
32
21
|
task :all do
|
33
22
|
build_time_zone_list ActiveSupport::TimeZone.all
|
34
23
|
end
|
35
24
|
|
36
|
-
# desc '
|
25
|
+
# desc 'Display names of US time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6'
|
37
26
|
task :us do
|
38
27
|
build_time_zone_list ActiveSupport::TimeZone.us_zones
|
39
28
|
end
|
40
29
|
|
41
|
-
# desc '
|
30
|
+
# desc 'Display names of time zones recognized by the Rails TimeZone class with the same offset as the system local time'
|
42
31
|
task :local do
|
43
32
|
require "active_support"
|
44
33
|
require "active_support/time"
|
@@ -26,12 +26,13 @@ STATS_DIRECTORIES ||= [
|
|
26
26
|
%w(Channel\ tests test/channels),
|
27
27
|
%w(Integration\ tests test/integration),
|
28
28
|
%w(System\ tests test/system),
|
29
|
-
]
|
30
|
-
[ name, "#{File.dirname(Rake.application.rakefile_location)}/#{dir}" ]
|
31
|
-
end.select { |name, dir| File.directory?(dir) }
|
29
|
+
]
|
32
30
|
|
33
31
|
desc "Report code statistics (KLOCs, etc) from the application or engine"
|
34
32
|
task :stats do
|
35
33
|
require "rails/code_statistics"
|
36
|
-
|
34
|
+
stat_directories = STATS_DIRECTORIES.collect do |name, dir|
|
35
|
+
[ name, "#{File.dirname(Rake.application.rakefile_location)}/#{dir}" ]
|
36
|
+
end.select { |name, dir| File.directory?(dir) }
|
37
|
+
CodeStatistics.new(*stat_directories).to_s
|
37
38
|
end
|
data/lib/rails/tasks/tmp.rake
CHANGED
@@ -7,36 +7,36 @@ namespace :tmp do
|
|
7
7
|
tmp_dirs = [ "tmp/cache",
|
8
8
|
"tmp/sockets",
|
9
9
|
"tmp/pids",
|
10
|
-
|
10
|
+
]
|
11
11
|
|
12
12
|
tmp_dirs.each { |d| directory d }
|
13
13
|
|
14
|
-
desc "
|
14
|
+
desc "Create tmp directories for cache, sockets, and pids"
|
15
15
|
task create: tmp_dirs
|
16
16
|
|
17
17
|
namespace :cache do
|
18
|
-
# desc "
|
18
|
+
# desc "Clear all files and directories in tmp/cache"
|
19
19
|
task :clear do
|
20
20
|
rm_rf Dir["tmp/cache/[^.]*"], verbose: false
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
namespace :sockets do
|
25
|
-
# desc "
|
25
|
+
# desc "Clear all files in tmp/sockets"
|
26
26
|
task :clear do
|
27
27
|
rm Dir["tmp/sockets/[^.]*"], verbose: false
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
namespace :pids do
|
32
|
-
# desc "
|
32
|
+
# desc "Clear all files in tmp/pids"
|
33
33
|
task :clear do
|
34
34
|
rm Dir["tmp/pids/[^.]*"], verbose: false
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
namespace :screenshots do
|
39
|
-
# desc "
|
39
|
+
# desc "Clear all files in tmp/screenshots"
|
40
40
|
task :clear do
|
41
41
|
rm Dir["tmp/screenshots/[^.]*"], verbose: false
|
42
42
|
end
|
@@ -1,11 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
puts "Hold on, I am eager loading the application."
|
5
|
-
Zeitwerk::Loader.eager_load_all
|
6
|
-
end
|
3
|
+
require "rails/zeitwerk_checker"
|
7
4
|
|
8
|
-
|
5
|
+
report_unchecked = ->(unchecked) do
|
9
6
|
puts
|
10
7
|
puts <<~EOS
|
11
8
|
WARNING: The following directories will only be checked if you configure
|
@@ -13,7 +10,7 @@ report_not_checked = ->(not_checked) do
|
|
13
10
|
EOS
|
14
11
|
puts
|
15
12
|
|
16
|
-
|
13
|
+
unchecked.each { |dir| puts " #{dir}" }
|
17
14
|
puts
|
18
15
|
|
19
16
|
puts <<~EOS
|
@@ -23,39 +20,22 @@ report_not_checked = ->(not_checked) do
|
|
23
20
|
puts
|
24
21
|
end
|
25
22
|
|
26
|
-
report = ->(not_checked) do
|
27
|
-
if not_checked.any?
|
28
|
-
report_not_checked[not_checked]
|
29
|
-
puts "Otherwise, all is good!"
|
30
|
-
else
|
31
|
-
puts "All is good!"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
23
|
namespace :zeitwerk do
|
36
|
-
desc "
|
24
|
+
desc "Check project structure for Zeitwerk compatibility"
|
37
25
|
task check: :environment do
|
26
|
+
puts "Hold on, I am eager loading the application."
|
27
|
+
|
38
28
|
begin
|
39
|
-
|
40
|
-
rescue NameError => e
|
41
|
-
|
42
|
-
abort $&.sub(/expected file #{Regexp.escape(Rails.root.to_s)}./, "expected file ")
|
43
|
-
else
|
44
|
-
raise
|
45
|
-
end
|
29
|
+
unchecked = Rails::ZeitwerkChecker.check
|
30
|
+
rescue Zeitwerk::NameError => e
|
31
|
+
abort e.message.sub(/#{Regexp.escape(Rails.root.to_s)}./, "")
|
46
32
|
end
|
47
33
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
not_checked = ActiveSupport::Dependencies.autoload_paths - eager_load_paths
|
56
|
-
not_checked.select! { |dir| Dir.exist?(dir) }
|
57
|
-
not_checked.reject! { |dir| Dir.empty?(dir) }
|
58
|
-
|
59
|
-
report[not_checked]
|
34
|
+
if unchecked.empty?
|
35
|
+
puts "All is good!"
|
36
|
+
else
|
37
|
+
report_unchecked[unchecked]
|
38
|
+
puts "Otherwise, all is good!"
|
39
|
+
end
|
60
40
|
end
|
61
41
|
end
|
data/lib/rails/tasks.rb
CHANGED
@@ -44,6 +44,13 @@
|
|
44
44
|
content: "\00a0"; //
|
45
45
|
}
|
46
46
|
|
47
|
+
th {
|
48
|
+
font-weight: inherit;
|
49
|
+
color: #7f7f7f;
|
50
|
+
text-align: right;
|
51
|
+
white-space: nowrap;
|
52
|
+
}
|
53
|
+
|
47
54
|
iframe {
|
48
55
|
border: 0;
|
49
56
|
width: 100%;
|
@@ -54,14 +61,14 @@
|
|
54
61
|
<body>
|
55
62
|
<header>
|
56
63
|
<dl>
|
57
|
-
<% if
|
64
|
+
<% if Array(@email.from) != Array(@email.smtp_envelope_from) %>
|
58
65
|
<dt>SMTP-From:</dt>
|
59
66
|
<dd id="smtp_from"><%= @email.smtp_envelope_from %></dd>
|
60
67
|
<% end %>
|
61
68
|
|
62
|
-
<% if
|
69
|
+
<% if Set[*@email.to, *@email.cc, *@email.bcc] != Set[*@email.smtp_envelope_to] %>
|
63
70
|
<dt>SMTP-To:</dt>
|
64
|
-
<dd id="smtp_to"><%= @email.smtp_envelope_to %></dd>
|
71
|
+
<dd id="smtp_to"><%= @email.smtp_envelope_to.join(", ") %></dd>
|
65
72
|
<% end %>
|
66
73
|
|
67
74
|
<dt>From:</dt>
|
@@ -80,18 +87,27 @@
|
|
80
87
|
<dd id="cc"><%= @email.header['cc'] %></dd>
|
81
88
|
<% end %>
|
82
89
|
|
90
|
+
<% if @email.bcc %>
|
91
|
+
<dt>BCC:</dt>
|
92
|
+
<dd id="bcc"><%= @email.header['bcc'] %></dd>
|
93
|
+
<% end %>
|
94
|
+
|
83
95
|
<dt>Date:</dt>
|
84
|
-
<dd id="date"><%= Time.current.rfc2822 %></dd>
|
96
|
+
<dd id="date"><%= @email.header['date'] || Time.current.rfc2822 %></dd>
|
85
97
|
|
86
98
|
<dt>Subject:</dt>
|
87
99
|
<dd><strong id="subject"><%= @email.subject %></strong></dd>
|
88
100
|
|
89
|
-
<%
|
101
|
+
<% if @attachments.any? || @inline_attachments.any? %>
|
90
102
|
<dt>Attachments:</dt>
|
91
103
|
<dd>
|
92
|
-
<% @
|
93
|
-
|
94
|
-
|
104
|
+
<% @attachments.each do |filename, attachment| %>
|
105
|
+
<%= link_to filename, attachment_url(attachment), download: filename %>
|
106
|
+
<% end %>
|
107
|
+
|
108
|
+
<% if @inline_attachments.any? %>
|
109
|
+
(Inline: <% @inline_attachments.each do |filename, attachment| %>
|
110
|
+
<%= link_to filename, attachment_url(attachment), download: filename %><% end %>)
|
95
111
|
<% end %>
|
96
112
|
</dd>
|
97
113
|
<% end %>
|
@@ -120,6 +136,26 @@
|
|
120
136
|
</select>
|
121
137
|
</dd>
|
122
138
|
<% end %>
|
139
|
+
|
140
|
+
<% unless @email.header_fields.nil? || @email.header_fields.empty? %>
|
141
|
+
<dt>Headers:</dt>
|
142
|
+
<dd>
|
143
|
+
<details>
|
144
|
+
<summary>Show all headers</summary>
|
145
|
+
<table>
|
146
|
+
<% @email.header_fields.each do |field| %>
|
147
|
+
<tr>
|
148
|
+
<th><%= field.name %>:</th>
|
149
|
+
<td><%= field.value %></td>
|
150
|
+
</tr>
|
151
|
+
<% end %>
|
152
|
+
</table>
|
153
|
+
</details>
|
154
|
+
</dd>
|
155
|
+
<% end %>
|
156
|
+
|
157
|
+
<dt>EML File:</dt>
|
158
|
+
<dd><%= link_to "Download", action: :download %></dd>
|
123
159
|
</dl>
|
124
160
|
</header>
|
125
161
|
|
@@ -1,8 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
<%
|
5
|
-
<
|
6
|
-
|
7
|
-
|
1
|
+
<h1><%= @page_title %></h1>
|
2
|
+
|
3
|
+
<% if @previews.any? %>
|
4
|
+
<% @previews.each do |preview| %>
|
5
|
+
<h3><%= link_to preview.preview_name.titleize, url_for(controller: "rails/mailers", action: "preview", path: preview.preview_name) %></h3>
|
6
|
+
<ul>
|
7
|
+
<% preview.emails.each do |email| %>
|
8
|
+
<li><%= link_to email, url_for(controller: "rails/mailers", action: "preview", path: "#{preview.preview_name}/#{email}") %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
<% end %>
|
12
|
+
<% else %>
|
13
|
+
<p>You have not defined any Action Mailer Previews.</p>
|
14
|
+
<p>Read <%= link_to "Action Mailer Basics", "https://guides.rubyonrails.org/action_mailer_basics.html#previewing-emails" %> to learn how to define your first.</p>
|
8
15
|
<% end %>
|
@@ -1,6 +1,12 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
<% @preview.emails.
|
4
|
-
<
|
1
|
+
<h1><%= @page_title %></h1>
|
2
|
+
|
3
|
+
<% if @preview.emails.any? %>
|
4
|
+
<ul>
|
5
|
+
<% @preview.emails.each do |email| %>
|
6
|
+
<li><%= link_to email, url_for(controller: "rails/mailers", action: "preview", path: "#{@preview.preview_name}/#{email}") %></li>
|
7
|
+
<% end %>
|
8
|
+
</ul>
|
9
|
+
<% else %>
|
10
|
+
<p>You have not defined any actions for <%= @preview %>.</p>
|
11
|
+
<p>Read <%= link_to "Action Mailer Basics", "https://guides.rubyonrails.org/action_mailer_basics.html#previewing-emails" %> to learn how to define your first.</p>
|
5
12
|
<% end %>
|
6
|
-
</ul>
|
@@ -1,11 +1,12 @@
|
|
1
|
-
<% ruby_on_rails_logo_favicon_data_uri = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIwcHgiIGhlaWdodD0iMzIwcHgiIHZpZXdCb3g9IjAgMCAzMjAgMzIwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPHRpdGxlPkljb248L3RpdGxlPgogICAgPGcgaWQ9Ikljb24iIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIGlkPSJSdWJ5LU9uLVJhaWxzLUxvZ28iIHRyYW5zZm9ybT0idHJhbnNsYXRlKDUuMDAwMDAwLCAyMC4wMDAwMDApIiBmaWxsPSIjRDgxRTAwIj4KICAgICAgICAgICAgPHBhdGggZD0iTTIxLjkzMzA3MDYsMjg1IEwxNjguMTc1NDI2LDI4NSBDMTQ3Ljk0MDg1OCwxNTAuNjkxNzA2IDE5Ni44ODIzODMsNjYuMzE0MjkwMiAzMTUsMzEuODY3NzUzNiBDMzE1LDIxLjc4NTEyODQgMzE1LDMxLjg2Nzc1MzYgMzE1LDIxLjc4NTEyODQgQzE2MS4yNTI4MywyNC45MTE2Mjc4IDYzLjU2Mzg1MzMsMTEyLjY0OTkxOCAyMS45MzMwNzA2LDI4NSBaIiBpZD0iUGF0aCIvPgogICAgICAgICAgICA8cG9seWdvbiBpZD0iUGF0aCIgcG9pbnRzPSI0MC40MDgyNjQzIDE4NS45MTU3MSAxMi43MzI2NDk0IDE3NC40MDE2NjMgLTEuNDIxMDg1NDdlLTE0IDIwNS40NDI3MSAyOS41NzExOTY2IDIxNi42NDcxMTUiLz4KICAgICAgICAgICAgPHBvbHlnb24gaWQ9IlBhdGgiIHBvaW50cz0iMTgwLjQ3MzEwMiAyNjguMDczNjQzIDIwNC45MzYwMTYgMjc2LjQxMDk2NiAyMDQuOTM2MDE2IDI1NC41MDg2NzMgMTgwLjQ4OTY0NCAyNDQuMzM4MTA3Ii8+CiAgICAgICAgICAgIDxwb2x5Z29uIGlkPSJQYXRoIiBwb2ludHM9IjEwMC41ODk1MTkgOTcuMjI4NzYwNiA3Ni42ODQwMTU2IDc5LjE2ODcwMjEgNTUuMjQ0MDc5MSAxMDAuMTgzMTA1IDgxLjUxNDMyMzkgMTE3LjQzMzcyNSIvPgogICAgICAgICAgICA8cG9seWdvbiBpZD0iUGF0aCIgcG9pbnRzPSIxODQuNTc1Njc5IDE4NC44OTYyOTUgMjA3Ljk1MjAzIDIwMC4yNDY2MSAyMTEuNzI3NzI5IDE4MS4yMDUyNjYgMTg5Ljg2MzY1MyAxNjQuNjg3NDYiLz4KICAgICAgICAgICAgPHBvbHlnb24gaWQ9IlBhdGgiIHBvaW50cz0iMjYxLjczNDAxIDY1Ljg5NTk0NDYgMjY5LjM1NDIzNCA4Mi4zMjk1NCAyODUuMzE4MjU2IDcyLjcwNDg1OTYgMjc4LjMxMDEyOSA1Ni45ODI5ODk1Ii8+CiAgICAgICAgICAgIDxwb2x5Z29uIGlkPSJQYXRoIiBwb2ludHM9IjI2MS45MTM3IDE2LjE4NDU0NzMgMjU1LjU5ODQ3OSA3LjEwNTQyNzM2ZS0xNSAyMzIuNzk2MDIgMy40ODg5NjMyMyAyNDAuNDYzODczIDIwLjAyNTI3MjUiLz4KICAgICAgICAgICAgPHBvbHlnb24gaWQ9IlBhdGgiIHBvaW50cz0iMjExLjkzNDExOSAxMTEuNTgwNjc1IDIyNi43MjI1NDcgMTI3Ljc5MjYwMSAyMzguMDIzOTI1IDExMy45MDM3MTUgMjIzLjQ2ODM3NSA5Ni41NDY4Njg1Ii8+CiAgICAgICAgICAgIDxwb2x5Z29uIGlkPSJQYXRoIiBwb2ludHM9IjE3OS42ODY4NTggMzguNDk1MjIxOCAxNjQuNjQxOTMxIDIwLjAyNTI3MjUgMTM5Ljg0NzYyIDMyLjU1NTI5OTIgMTU2LjYwMTMyNCA1MC45MjE2NzUzIi8+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=" %>
|
2
1
|
<!DOCTYPE html>
|
3
2
|
<html>
|
4
3
|
<head>
|
5
4
|
<title>Ruby on Rails <%= Rails.version %></title>
|
6
5
|
<meta charset="utf-8">
|
7
6
|
<meta name="viewport" content="width=device-width">
|
8
|
-
|
7
|
+
|
8
|
+
<link rel="icon" href="/icon.png" type="image/png">
|
9
|
+
<link rel="apple-touch-icon" href="/icon.png" sizes="512x512">
|
9
10
|
|
10
11
|
<style type="text/css">
|
11
12
|
* {
|
@@ -50,6 +51,7 @@
|
|
50
51
|
border-radius: 100%;
|
51
52
|
display: flex;
|
52
53
|
transition: background 0.25s cubic-bezier(0.33, 1, 0.68, 1);
|
54
|
+
filter: drop-shadow(0 20px 13px rgb(0 0 0 / 0.03)) drop-shadow(0 8px 5px rgb(0 0 0 / 0.08));
|
53
55
|
}
|
54
56
|
|
55
57
|
nav a:hover {
|
@@ -83,6 +85,7 @@
|
|
83
85
|
|
84
86
|
<ul>
|
85
87
|
<li><strong>Rails version:</strong> <%= Rails.version %></li>
|
88
|
+
<li><strong>Rack version:</strong> <%= Rack.release %></li>
|
86
89
|
<li><strong>Ruby version:</strong> <%= RUBY_DESCRIPTION %></li>
|
87
90
|
</ul>
|
88
91
|
</body>
|
data/lib/rails/test_help.rb
CHANGED
@@ -1,35 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :enddoc:
|
4
|
+
|
3
5
|
# Make double-sure the RAILS_ENV is not set to production,
|
4
6
|
# so fixtures aren't loaded into that environment
|
5
7
|
abort("Abort testing: Your Rails environment is running in production mode!") if Rails.env.production?
|
6
8
|
|
7
9
|
require "active_support/test_case"
|
8
|
-
require "action_controller"
|
9
|
-
require "action_controller/test_case"
|
10
|
-
require "action_dispatch/testing/integration"
|
11
10
|
require "rails/generators/test_case"
|
12
|
-
|
13
11
|
require "active_support/testing/autorun"
|
14
12
|
|
15
|
-
|
16
|
-
begin
|
17
|
-
ActiveRecord::Migration.maintain_test_schema!
|
18
|
-
rescue ActiveRecord::PendingMigrationError => e
|
19
|
-
puts e.to_s.strip
|
20
|
-
exit 1
|
21
|
-
end
|
13
|
+
require "rails/testing/maintain_test_schema"
|
22
14
|
|
15
|
+
if defined?(ActiveRecord::Base)
|
16
|
+
require "active_record/testing/query_assertions"
|
23
17
|
ActiveSupport.on_load(:active_support_test_case) do
|
24
18
|
include ActiveRecord::TestDatabases
|
25
19
|
include ActiveRecord::TestFixtures
|
20
|
+
include ActiveRecord::Assertions::QueryAssertions
|
26
21
|
|
27
|
-
self.
|
28
|
-
self.file_fixture_path =
|
22
|
+
self.fixture_paths << "#{Rails.root}/test/fixtures/"
|
23
|
+
self.file_fixture_path = "#{Rails.root}/test/fixtures/files"
|
29
24
|
end
|
30
25
|
|
31
26
|
ActiveSupport.on_load(:action_dispatch_integration_test) do
|
32
|
-
self.
|
27
|
+
self.fixture_paths += ActiveSupport::TestCase.fixture_paths
|
33
28
|
end
|
34
29
|
else
|
35
30
|
ActiveSupport.on_load(:active_support_test_case) do
|
@@ -37,17 +32,15 @@ else
|
|
37
32
|
end
|
38
33
|
end
|
39
34
|
|
40
|
-
# :enddoc:
|
41
|
-
|
42
35
|
ActiveSupport.on_load(:action_controller_test_case) do
|
43
|
-
def before_setup
|
36
|
+
def before_setup
|
44
37
|
@routes = Rails.application.routes
|
45
38
|
super
|
46
39
|
end
|
47
40
|
end
|
48
41
|
|
49
42
|
ActiveSupport.on_load(:action_dispatch_integration_test) do
|
50
|
-
def before_setup
|
43
|
+
def before_setup
|
51
44
|
@routes = Rails.application.routes
|
52
45
|
super
|
53
46
|
end
|