railties 5.1.7 → 5.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +77 -241
- data/RDOC_MAIN.rdoc +61 -43
- data/README.rdoc +1 -2
- data/exe/rails +3 -2
- data/lib/minitest/rails_plugin.rb +9 -13
- data/lib/rails.rb +4 -2
- data/lib/rails/all.rb +3 -0
- data/lib/rails/api/generator.rb +10 -1
- data/lib/rails/api/task.rb +11 -1
- data/lib/rails/app_loader.rb +18 -5
- data/lib/rails/app_updater.rb +34 -0
- data/lib/rails/application.rb +90 -18
- data/lib/rails/application/bootstrap.rb +2 -0
- data/lib/rails/application/configuration.rb +79 -36
- data/lib/rails/application/default_middleware_stack.rb +7 -1
- data/lib/rails/application/finisher.rb +3 -1
- data/lib/rails/application/routes_reloader.rb +21 -3
- data/lib/rails/application_controller.rb +3 -1
- data/lib/rails/backtrace_cleaner.rb +3 -1
- data/lib/rails/cli.rb +2 -0
- data/lib/rails/code_statistics.rb +2 -0
- data/lib/rails/code_statistics_calculator.rb +2 -0
- data/lib/rails/command.rb +3 -1
- data/lib/rails/command/actions.rb +6 -4
- data/lib/rails/command/base.rb +5 -3
- data/lib/rails/command/behavior.rb +2 -0
- data/lib/rails/command/environment_argument.rb +14 -1
- data/lib/rails/command/helpers/editor.rb +35 -0
- data/lib/rails/commands.rb +2 -0
- data/lib/rails/commands/application/application_command.rb +2 -0
- data/lib/rails/commands/console/console_command.rb +2 -3
- data/lib/rails/commands/credentials/USAGE +40 -0
- data/lib/rails/commands/credentials/credentials_command.rb +72 -0
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +18 -7
- data/lib/rails/commands/destroy/destroy_command.rb +2 -0
- data/lib/rails/commands/encrypted/encrypted_command.rb +77 -0
- data/lib/rails/commands/generate/generate_command.rb +2 -0
- data/lib/rails/commands/help/help_command.rb +2 -0
- data/lib/rails/commands/new/new_command.rb +2 -0
- data/lib/rails/commands/plugin/plugin_command.rb +2 -0
- data/lib/rails/commands/rake/rake_command.rb +2 -0
- data/lib/rails/commands/runner/USAGE +3 -0
- data/lib/rails/commands/runner/runner_command.rb +7 -3
- data/lib/rails/commands/secrets/secrets_command.rb +15 -10
- data/lib/rails/commands/server/server_command.rb +24 -3
- data/lib/rails/commands/test/test_command.rb +18 -23
- data/lib/rails/commands/version/version_command.rb +2 -0
- data/lib/rails/configuration.rb +2 -0
- data/lib/rails/console/app.rb +2 -0
- data/lib/rails/console/helpers.rb +2 -0
- data/lib/rails/dev_caching.rb +2 -1
- data/lib/rails/engine.rb +3 -1
- data/lib/rails/engine/commands.rb +2 -0
- data/lib/rails/engine/configuration.rb +2 -0
- data/lib/rails/engine/railties.rb +2 -0
- data/lib/rails/engine/updater.rb +3 -1
- data/lib/rails/gem_version.rb +5 -3
- data/lib/rails/generators.rb +8 -3
- data/lib/rails/generators/actions.rb +53 -24
- data/lib/rails/generators/actions/create_migration.rb +2 -0
- data/lib/rails/generators/active_model.rb +2 -0
- data/lib/rails/generators/app_base.rb +94 -57
- data/lib/rails/generators/base.rb +40 -1
- data/lib/rails/generators/css/assets/assets_generator.rb +3 -1
- data/lib/rails/generators/css/scaffold/scaffold_generator.rb +5 -3
- data/lib/rails/generators/erb.rb +2 -0
- data/lib/rails/generators/erb/controller/controller_generator.rb +2 -0
- data/lib/rails/generators/erb/controller/templates/{view.html.erb → view.html.erb.tt} +0 -0
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +2 -0
- data/lib/rails/generators/erb/mailer/templates/{view.html.erb → view.html.erb.tt} +0 -0
- data/lib/rails/generators/erb/mailer/templates/{view.text.erb → view.text.erb.tt} +0 -0
- data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +2 -0
- data/lib/rails/generators/erb/scaffold/templates/{_form.html.erb → _form.html.erb.tt} +4 -4
- data/lib/rails/generators/erb/scaffold/templates/{edit.html.erb → edit.html.erb.tt} +0 -0
- data/lib/rails/generators/erb/scaffold/templates/{index.html.erb → index.html.erb.tt} +4 -4
- data/lib/rails/generators/erb/scaffold/templates/{new.html.erb → new.html.erb.tt} +0 -0
- data/lib/rails/generators/erb/scaffold/templates/{show.html.erb → show.html.erb.tt} +0 -0
- data/lib/rails/generators/generated_attribute.rb +3 -1
- data/lib/rails/generators/js/assets/assets_generator.rb +3 -1
- data/lib/rails/generators/migration.rb +2 -0
- data/lib/rails/generators/model_helpers.rb +2 -0
- data/lib/rails/generators/named_base.rb +35 -45
- data/lib/rails/generators/rails/app/app_generator.rb +64 -23
- data/lib/rails/generators/rails/app/templates/{Gemfile → Gemfile.tt} +17 -6
- data/lib/rails/generators/rails/app/templates/{README.md → README.md.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/{Rakefile → Rakefile.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +3 -0
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/{cable.js → cable.js.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/{application.css → application.css.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/{channel.rb → channel.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/{connection.rb → connection.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +1 -4
- data/lib/rails/generators/rails/app/templates/app/helpers/{application_helper.rb → application_helper.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/jobs/{application_job.rb → application_job.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/mailers/{application_mailer.rb → application_mailer.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/models/{application_record.rb → application_record.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/bin/bundle.tt +2 -0
- data/lib/rails/generators/rails/app/templates/bin/{rails → rails.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/bin/{rake → rake.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +5 -5
- data/lib/rails/generators/rails/app/templates/bin/update.tt +7 -3
- data/lib/rails/generators/rails/app/templates/bin/{yarn → yarn.tt} +3 -3
- data/lib/rails/generators/rails/app/templates/{config.ru → config.ru.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/{application.rb → application.rb.tt} +2 -1
- data/lib/rails/generators/rails/app/templates/config/{boot.rb → boot.rb.tt} +1 -0
- data/lib/rails/generators/rails/app/templates/config/{cable.yml → cable.yml.tt} +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/{frontbase.yml → frontbase.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{ibm_db.yml → ibm_db.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{jdbc.yml → jdbc.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{jdbcmysql.yml → jdbcmysql.yml.tt} +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/{jdbcpostgresql.yml → jdbcpostgresql.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{jdbcsqlite3.yml → jdbcsqlite3.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{mysql.yml → mysql.yml.tt} +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/{oracle.yml → oracle.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{postgresql.yml → postgresql.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{sqlite3.yml → sqlite3.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{sqlserver.yml → sqlserver.yml.tt} +2 -2
- data/lib/rails/generators/rails/app/templates/config/{environment.rb → environment.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +7 -1
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +12 -7
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +8 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/{application_controller_renderer.rb → application_controller_renderer.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{backtrace_silencers.rb → backtrace_silencers.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +20 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{cookies_serializer.rb → cookies_serializer.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{cors.rb → cors.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{filter_parameter_logging.rb → filter_parameter_logging.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{inflections.rb → inflections.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{mime_types.rb → mime_types.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_2.rb.tt +27 -0
- data/lib/rails/generators/rails/app/templates/config/{puma.rb → puma.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/{routes.rb → routes.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/{spring.rb → spring.rb.tt} +2 -2
- data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +35 -0
- data/lib/rails/generators/rails/app/templates/{gitignore → gitignore.tt} +9 -1
- data/lib/rails/generators/rails/app/templates/{package.json → package.json.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/ruby-version.tt +1 -0
- data/lib/rails/generators/rails/app/templates/test/{application_system_test_case.rb → application_system_test_case.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/test/{test_helper.rb → test_helper.rb.tt} +1 -2
- data/lib/rails/generators/rails/application_record/application_record_generator.rb +9 -0
- data/lib/rails/generators/rails/assets/assets_generator.rb +2 -0
- data/lib/rails/generators/rails/assets/templates/stylesheet.css +1 -1
- data/lib/rails/generators/rails/controller/controller_generator.rb +11 -9
- data/lib/rails/generators/rails/controller/templates/{controller.rb → controller.rb.tt} +0 -0
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +48 -0
- data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +38 -0
- data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +57 -0
- data/lib/rails/generators/rails/generator/generator_generator.rb +2 -0
- data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +1 -1
- data/lib/rails/generators/rails/helper/helper_generator.rb +2 -0
- data/lib/rails/generators/rails/helper/templates/{helper.rb → helper.rb.tt} +0 -0
- data/lib/rails/generators/rails/integration_test/integration_test_generator.rb +2 -0
- data/lib/rails/generators/rails/master_key/master_key_generator.rb +51 -0
- data/lib/rails/generators/rails/migration/migration_generator.rb +2 -0
- data/lib/rails/generators/rails/model/model_generator.rb +2 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +18 -9
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +24 -0
- data/lib/rails/generators/rails/plugin/templates/{Gemfile → Gemfile.tt} +1 -0
- data/lib/rails/generators/rails/plugin/templates/{MIT-LICENSE → MIT-LICENSE.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/{README.md → README.md.tt} +1 -1
- data/lib/rails/generators/rails/plugin/templates/{Rakefile → Rakefile.tt} +6 -7
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +21 -4
- data/lib/rails/generators/rails/plugin/templates/bin/test.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/config/{routes.rb → routes.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +18 -0
- data/lib/rails/generators/rails/plugin/templates/lib/{%namespaced_name%.rb → %namespaced_name%.rb.tt} +3 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/{engine.rb → engine.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/{version.rb → version.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/lib/tasks/{%namespaced_name%_tasks.rake → %namespaced_name%_tasks.rake.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/rails/{application.rb → application.rb.tt} +6 -3
- data/lib/rails/generators/rails/plugin/templates/rails/{boot.rb → boot.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/rails/{dummy_manifest.js → dummy_manifest.js.tt} +0 -1
- data/lib/rails/generators/rails/plugin/templates/rails/{engine_manifest.js → engine_manifest.js.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/rails/{javascripts.js → javascripts.js.tt} +3 -0
- data/lib/rails/generators/rails/plugin/templates/rails/{routes.rb → routes.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/test/{%namespaced_name%_test.rb → %namespaced_name%_test.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/test/{application_system_test_case.rb → application_system_test_case.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/test/integration/{navigation_test.rb → navigation_test.rb.tt} +0 -1
- data/lib/rails/generators/rails/plugin/templates/test/{test_helper.rb → test_helper.rb.tt} +7 -6
- data/lib/rails/generators/rails/resource/USAGE +1 -1
- data/lib/rails/generators/rails/resource/resource_generator.rb +2 -0
- data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +21 -24
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -3
- data/lib/rails/generators/rails/scaffold_controller/USAGE +1 -1
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +2 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/{api_controller.rb → api_controller.rb.tt} +0 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/{controller.rb → controller.rb.tt} +2 -2
- data/lib/rails/generators/rails/system_test/system_test_generator.rb +2 -0
- data/lib/rails/generators/rails/task/task_generator.rb +2 -0
- data/lib/rails/generators/rails/task/templates/{task.rb → task.rb.tt} +0 -0
- data/lib/rails/generators/resource_helpers.rb +2 -0
- data/lib/rails/generators/test_case.rb +4 -2
- data/lib/rails/generators/test_unit.rb +2 -0
- data/lib/rails/generators/test_unit/controller/controller_generator.rb +2 -0
- data/lib/rails/generators/test_unit/controller/templates/{functional_test.rb → functional_test.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/generator/generator_generator.rb +2 -0
- data/lib/rails/generators/test_unit/generator/templates/{generator_test.rb → generator_test.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/helper/helper_generator.rb +2 -0
- data/lib/rails/generators/test_unit/integration/integration_generator.rb +2 -0
- data/lib/rails/generators/test_unit/integration/templates/{integration_test.rb → integration_test.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/job/job_generator.rb +3 -1
- data/lib/rails/generators/test_unit/job/templates/{unit_test.rb.erb → unit_test.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +2 -0
- data/lib/rails/generators/test_unit/mailer/templates/{functional_test.rb → functional_test.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/mailer/templates/{preview.rb → preview.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/model/model_generator.rb +2 -0
- data/lib/rails/generators/test_unit/model/templates/{fixtures.yml → fixtures.yml.tt} +0 -0
- data/lib/rails/generators/test_unit/model/templates/{unit_test.rb → unit_test.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +2 -0
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +17 -4
- data/lib/rails/generators/test_unit/scaffold/templates/{api_functional_test.rb → api_functional_test.rb.tt} +2 -2
- data/lib/rails/generators/test_unit/scaffold/templates/{functional_test.rb → functional_test.rb.tt} +2 -2
- data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +49 -0
- data/lib/rails/generators/test_unit/system/system_generator.rb +3 -1
- data/lib/rails/generators/test_unit/system/templates/{application_system_test_case.rb → application_system_test_case.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/system/templates/{system_test.rb → system_test.rb.tt} +0 -0
- data/lib/rails/generators/testing/assertions.rb +7 -1
- data/lib/rails/generators/testing/behaviour.rb +8 -6
- data/lib/rails/generators/testing/setup_and_teardown.rb +2 -0
- data/lib/rails/info.rb +6 -3
- data/lib/rails/info_controller.rb +2 -0
- data/lib/rails/initializable.rb +2 -0
- data/lib/rails/mailers_controller.rb +9 -1
- data/lib/rails/paths.rb +2 -0
- data/lib/rails/plugin/test.rb +4 -2
- data/lib/rails/rack.rb +2 -0
- data/lib/rails/rack/logger.rb +5 -3
- data/lib/rails/railtie.rb +9 -4
- data/lib/rails/railtie/configurable.rb +2 -0
- data/lib/rails/railtie/configuration.rb +2 -0
- data/lib/rails/ruby_version_check.rb +3 -1
- data/lib/rails/secrets.rb +2 -17
- data/lib/rails/source_annotation_extractor.rb +4 -2
- data/lib/rails/tasks.rb +2 -0
- data/lib/rails/tasks/annotations.rake +2 -0
- data/lib/rails/tasks/dev.rake +2 -0
- data/lib/rails/tasks/engine.rake +7 -2
- data/lib/rails/tasks/framework.rake +9 -24
- data/lib/rails/tasks/initializers.rake +2 -0
- data/lib/rails/tasks/log.rake +2 -0
- data/lib/rails/tasks/middleware.rake +2 -0
- data/lib/rails/tasks/misc.rake +2 -0
- data/lib/rails/tasks/restart.rake +2 -1
- data/lib/rails/tasks/routes.rake +2 -0
- data/lib/rails/tasks/statistics.rake +2 -0
- data/lib/rails/tasks/tmp.rake +11 -2
- data/lib/rails/tasks/yarn.rake +3 -1
- data/lib/rails/templates/rails/mailers/email.html.erb +3 -3
- data/lib/rails/templates/rails/welcome/index.html.erb +14 -4
- data/lib/rails/test_help.rb +2 -0
- data/lib/rails/test_unit/line_filtering.rb +2 -1
- data/lib/rails/test_unit/railtie.rb +2 -0
- data/lib/rails/test_unit/reporter.rb +5 -10
- data/lib/rails/test_unit/runner.rb +3 -3
- data/lib/rails/test_unit/testing.rake +3 -1
- data/lib/rails/version.rb +2 -0
- data/lib/rails/welcome_controller.rb +2 -0
- metadata +121 -107
- data/lib/rails/generators/rails/app/templates/bin/bundle +0 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt +0 -16
- data/lib/rails/generators/rails/app/templates/config/secrets.yml +0 -32
- data/lib/rails/generators/rails/encrypted_secrets/encrypted_secrets_generator.rb +0 -70
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec +0 -33
- data/lib/rails/generators/rails/plugin/templates/gitignore +0 -9
File without changes
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rails/generators/test_unit"
|
2
4
|
|
3
5
|
module TestUnit # :nodoc:
|
@@ -6,7 +8,7 @@ module TestUnit # :nodoc:
|
|
6
8
|
check_class_collision suffix: "JobTest"
|
7
9
|
|
8
10
|
def create_test_file
|
9
|
-
template "unit_test.rb
|
11
|
+
template "unit_test.rb", File.join("test/jobs", class_path, "#{file_name}_job_test.rb")
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
File without changes
|
data/lib/rails/generators/test_unit/mailer/templates/{functional_test.rb → functional_test.rb.tt}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rails/generators/test_unit"
|
2
4
|
require "rails/generators/resource_helpers"
|
3
5
|
|
@@ -11,12 +13,19 @@ module TestUnit # :nodoc:
|
|
11
13
|
class_option :api, type: :boolean,
|
12
14
|
desc: "Generates API functional tests"
|
13
15
|
|
16
|
+
class_option :system_tests, type: :string,
|
17
|
+
desc: "Skip system test files"
|
18
|
+
|
14
19
|
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
15
20
|
|
16
21
|
def create_test_files
|
17
22
|
template_file = options.api? ? "api_functional_test.rb" : "functional_test.rb"
|
18
23
|
template template_file,
|
19
24
|
File.join("test/controllers", controller_class_path, "#{controller_file_name}_controller_test.rb")
|
25
|
+
|
26
|
+
unless options.api? || options[:system_tests].nil?
|
27
|
+
template "system_test.rb", File.join("test/system", class_path, "#{file_name.pluralize}_test.rb")
|
28
|
+
end
|
20
29
|
end
|
21
30
|
|
22
31
|
def fixture_name
|
@@ -30,16 +39,20 @@ module TestUnit # :nodoc:
|
|
30
39
|
|
31
40
|
private
|
32
41
|
|
42
|
+
def attributes_string
|
43
|
+
attributes_hash.map { |k, v| "#{k}: #{v}" }.join(", ")
|
44
|
+
end
|
45
|
+
|
33
46
|
def attributes_hash
|
34
|
-
return if attributes_names.empty?
|
47
|
+
return {} if attributes_names.empty?
|
35
48
|
|
36
49
|
attributes_names.map do |name|
|
37
50
|
if %w(password password_confirmation).include?(name) && attributes.any?(&:password_digest?)
|
38
|
-
"#{name}
|
51
|
+
["#{name}", "'secret'"]
|
39
52
|
else
|
40
|
-
"#{name}
|
53
|
+
["#{name}", "@#{singular_table_name}.#{name}"]
|
41
54
|
end
|
42
|
-
end.sort.
|
55
|
+
end.sort.to_h
|
43
56
|
end
|
44
57
|
end
|
45
58
|
end
|
@@ -17,7 +17,7 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
|
|
17
17
|
|
18
18
|
test "should create <%= singular_table_name %>" do
|
19
19
|
assert_difference('<%= class_name %>.count') do
|
20
|
-
post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{
|
20
|
+
post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
|
21
21
|
end
|
22
22
|
|
23
23
|
assert_response 201
|
@@ -29,7 +29,7 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
|
|
29
29
|
end
|
30
30
|
|
31
31
|
test "should update <%= singular_table_name %>" do
|
32
|
-
patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{
|
32
|
+
patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
|
33
33
|
assert_response 200
|
34
34
|
end
|
35
35
|
|
data/lib/rails/generators/test_unit/scaffold/templates/{functional_test.rb → functional_test.rb.tt}
RENAMED
@@ -22,7 +22,7 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
|
|
22
22
|
|
23
23
|
test "should create <%= singular_table_name %>" do
|
24
24
|
assert_difference('<%= class_name %>.count') do
|
25
|
-
post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{
|
25
|
+
post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
|
26
26
|
end
|
27
27
|
|
28
28
|
assert_redirected_to <%= singular_table_name %>_url(<%= class_name %>.last)
|
@@ -39,7 +39,7 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
|
|
39
39
|
end
|
40
40
|
|
41
41
|
test "should update <%= singular_table_name %>" do
|
42
|
-
patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{
|
42
|
+
patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
|
43
43
|
assert_redirected_to <%= singular_table_name %>_url(<%= "@#{singular_table_name}" %>)
|
44
44
|
end
|
45
45
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
|
5
|
+
setup do
|
6
|
+
@<%= singular_table_name %> = <%= fixture_name %>(:one)
|
7
|
+
end
|
8
|
+
|
9
|
+
test "visiting the index" do
|
10
|
+
visit <%= plural_table_name %>_url
|
11
|
+
assert_selector "h1", text: "<%= class_name.pluralize.titleize %>"
|
12
|
+
end
|
13
|
+
|
14
|
+
test "creating a <%= human_name %>" do
|
15
|
+
visit <%= plural_table_name %>_url
|
16
|
+
click_on "New <%= class_name.titleize %>"
|
17
|
+
|
18
|
+
<%- attributes_hash.each do |attr, value| -%>
|
19
|
+
fill_in "<%= attr.humanize.titleize %>", with: <%= value %>
|
20
|
+
<%- end -%>
|
21
|
+
click_on "Create <%= human_name %>"
|
22
|
+
|
23
|
+
assert_text "<%= human_name %> was successfully created"
|
24
|
+
click_on "Back"
|
25
|
+
end
|
26
|
+
|
27
|
+
test "updating a <%= human_name %>" do
|
28
|
+
visit <%= plural_table_name %>_url
|
29
|
+
click_on "Edit", match: :first
|
30
|
+
|
31
|
+
<%- attributes_hash.each do |attr, value| -%>
|
32
|
+
fill_in "<%= attr.humanize.titleize %>", with: <%= value %>
|
33
|
+
<%- end -%>
|
34
|
+
click_on "Update <%= human_name %>"
|
35
|
+
|
36
|
+
assert_text "<%= human_name %> was successfully updated"
|
37
|
+
click_on "Back"
|
38
|
+
end
|
39
|
+
|
40
|
+
test "destroying a <%= human_name %>" do
|
41
|
+
visit <%= plural_table_name %>_url
|
42
|
+
page.accept_confirm do
|
43
|
+
click_on "Destroy", match: :first
|
44
|
+
end
|
45
|
+
|
46
|
+
assert_text "<%= human_name %> was successfully destroyed"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
<% end -%>
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rails/generators/test_unit"
|
2
4
|
|
3
5
|
module TestUnit # :nodoc:
|
@@ -10,7 +12,7 @@ module TestUnit # :nodoc:
|
|
10
12
|
template "application_system_test_case.rb", File.join("test", "application_system_test_case.rb")
|
11
13
|
end
|
12
14
|
|
13
|
-
template "system_test.rb", File.join("test/system", "#{file_name.pluralize}_test.rb")
|
15
|
+
template "system_test.rb", File.join("test/system", class_path, "#{file_name.pluralize}_test.rb")
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
File without changes
|
File without changes
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Rails
|
2
4
|
module Generators
|
3
5
|
module Testing
|
@@ -113,7 +115,11 @@ module Rails
|
|
113
115
|
#
|
114
116
|
# assert_field_default_value :string, "MyString"
|
115
117
|
def assert_field_default_value(attribute_type, value)
|
116
|
-
|
118
|
+
if value.nil?
|
119
|
+
assert_nil(create_generated_attribute(attribute_type).default)
|
120
|
+
else
|
121
|
+
assert_equal(value, create_generated_attribute(attribute_type).default)
|
122
|
+
end
|
117
123
|
end
|
118
124
|
end
|
119
125
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/core_ext/class/attribute"
|
2
4
|
require "active_support/core_ext/module/delegation"
|
3
5
|
require "active_support/core_ext/hash/reverse_merge"
|
@@ -14,12 +16,12 @@ module Rails
|
|
14
16
|
include ActiveSupport::Testing::Stream
|
15
17
|
|
16
18
|
included do
|
17
|
-
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
|
18
|
-
|
19
19
|
# Generators frequently change the current path using +FileUtils.cd+.
|
20
20
|
# So we need to store the path at file load and revert back to it after each test.
|
21
|
-
|
22
|
-
|
21
|
+
class_attribute :current_path, default: File.expand_path(Dir.pwd)
|
22
|
+
class_attribute :default_arguments, default: []
|
23
|
+
class_attribute :destination_root
|
24
|
+
class_attribute :generator_class
|
23
25
|
end
|
24
26
|
|
25
27
|
module ClassMethods
|
@@ -40,7 +42,7 @@ module Rails
|
|
40
42
|
|
41
43
|
# Sets the destination of generator files:
|
42
44
|
#
|
43
|
-
# destination File.expand_path("../tmp",
|
45
|
+
# destination File.expand_path("../tmp", __dir__)
|
44
46
|
def destination(path)
|
45
47
|
self.destination_root = path
|
46
48
|
end
|
@@ -51,7 +53,7 @@ module Rails
|
|
51
53
|
#
|
52
54
|
# class AppGeneratorTest < Rails::Generators::TestCase
|
53
55
|
# tests AppGenerator
|
54
|
-
# destination File.expand_path("../tmp",
|
56
|
+
# destination File.expand_path("../tmp", __dir__)
|
55
57
|
# setup :prepare_destination
|
56
58
|
#
|
57
59
|
# test "database.yml is not created when skipping Active Record" do
|
data/lib/rails/info.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "cgi"
|
2
4
|
|
3
5
|
module Rails
|
@@ -5,8 +7,9 @@ module Rails
|
|
5
7
|
# Rails::InfoController responses. These include the active Rails version,
|
6
8
|
# Ruby version, Rack version, and so on.
|
7
9
|
module Info
|
8
|
-
mattr_accessor :properties
|
9
|
-
|
10
|
+
mattr_accessor :properties, default: []
|
11
|
+
|
12
|
+
class << @@properties
|
10
13
|
def names
|
11
14
|
map(&:first)
|
12
15
|
end
|
@@ -38,7 +41,7 @@ module Rails
|
|
38
41
|
alias inspect to_s
|
39
42
|
|
40
43
|
def to_html
|
41
|
-
"<table>".tap do |table|
|
44
|
+
"<table>".dup.tap do |table|
|
42
45
|
properties.each do |(name, value)|
|
43
46
|
table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
|
44
47
|
formatted_value = if value.kind_of?(Array)
|
data/lib/rails/initializable.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rails/application_controller"
|
2
4
|
|
3
5
|
class Rails::MailersController < Rails::ApplicationController # :nodoc:
|
@@ -6,6 +8,8 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc:
|
|
6
8
|
before_action :require_local!, unless: :show_previews?
|
7
9
|
before_action :find_preview, only: :preview
|
8
10
|
|
11
|
+
helper_method :part_query
|
12
|
+
|
9
13
|
def index
|
10
14
|
@previews = ActionMailer::Preview.all
|
11
15
|
@page_title = "Mailer Previews"
|
@@ -19,7 +23,7 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc:
|
|
19
23
|
@email_action = File.basename(params[:path])
|
20
24
|
|
21
25
|
if @preview.email_exists?(@email_action)
|
22
|
-
@email = @preview.call(@email_action)
|
26
|
+
@email = @preview.call(@email_action, params)
|
23
27
|
|
24
28
|
if params[:part]
|
25
29
|
part_type = Mime::Type.lookup(params[:part])
|
@@ -76,4 +80,8 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc:
|
|
76
80
|
@email
|
77
81
|
end
|
78
82
|
end
|
83
|
+
|
84
|
+
def part_query(mime_type)
|
85
|
+
request.query_parameters.merge(part: mime_type).to_query
|
86
|
+
end
|
79
87
|
end
|
data/lib/rails/paths.rb
CHANGED
data/lib/rails/plugin/test.rb
CHANGED
data/lib/rails/rack.rb
CHANGED
data/lib/rails/rack/logger.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/core_ext/time/conversions"
|
2
4
|
require "active_support/core_ext/object/blank"
|
3
5
|
require "active_support/log_subscriber"
|
@@ -33,9 +35,9 @@ module Rails
|
|
33
35
|
instrumenter = ActiveSupport::Notifications.instrumenter
|
34
36
|
instrumenter.start "request.action_dispatch", request: request
|
35
37
|
logger.info { started_request_message(request) }
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
resp = @app.call(env)
|
39
|
+
resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) }
|
40
|
+
resp
|
39
41
|
rescue Exception
|
40
42
|
finish(request)
|
41
43
|
raise
|
data/lib/rails/railtie.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rails/initializable"
|
2
4
|
require "active_support/inflector"
|
3
5
|
require "active_support/core_ext/module/introspection"
|
@@ -103,6 +105,9 @@ module Rails
|
|
103
105
|
# end
|
104
106
|
# end
|
105
107
|
#
|
108
|
+
# Since filenames on the load path are shared across gems, be sure that files you load
|
109
|
+
# through a railtie have unique names.
|
110
|
+
#
|
106
111
|
# == Application and Engine
|
107
112
|
#
|
108
113
|
# An engine is nothing more than a railtie with some initializers already set. And since
|
@@ -162,10 +167,6 @@ module Rails
|
|
162
167
|
@instance ||= new
|
163
168
|
end
|
164
169
|
|
165
|
-
def respond_to_missing?(*args)
|
166
|
-
instance.respond_to?(*args) || super
|
167
|
-
end
|
168
|
-
|
169
170
|
# Allows you to configure the railtie. This is the same method seen in
|
170
171
|
# Railtie::Configurable, but this module is no longer required for all
|
171
172
|
# subclasses of Railtie so we provide the class method here.
|
@@ -178,6 +179,10 @@ module Rails
|
|
178
179
|
ActiveSupport::Inflector.underscore(string).tr("/", "_")
|
179
180
|
end
|
180
181
|
|
182
|
+
def respond_to_missing?(name, _)
|
183
|
+
instance.respond_to?(name) || super
|
184
|
+
end
|
185
|
+
|
181
186
|
# If the class method does not have a method, then send the method call
|
182
187
|
# to the Railtie instance.
|
183
188
|
def method_missing(name, *args, &block)
|