aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/CHANGELOG.md2
-rw-r--r--activerecord/lib/active_record/associations/belongs_to_association.rb4
-rw-r--r--activerecord/lib/active_record/associations/builder/belongs_to.rb2
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/quoting.rb6
-rw-r--r--activerecord/test/cases/adapter_test.rb9
-rw-r--r--activesupport/CHANGELOG.md14
-rw-r--r--guides/source/5_1_release_notes.md60
-rw-r--r--guides/source/action_mailer_basics.md5
-rw-r--r--guides/source/active_job_basics.md2
-rw-r--r--guides/source/caching_with_rails.md16
-rw-r--r--guides/source/security.md13
-rw-r--r--guides/source/working_with_javascript_in_rails.md2
-rw-r--r--railties/lib/rails/application/configuration.rb28
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb8
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/application.rb3
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt37
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt13
-rw-r--r--railties/test/generators/api_app_generator_test.rb9
-rw-r--r--railties/test/generators/app_generator_test.rb33
-rw-r--r--railties/test/generators/encrypted_secrets_generator_test.rb6
-rw-r--r--railties/test/railties/mounted_engine_test.rb2
21 files changed, 162 insertions, 112 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 6506cd4c02..4488524c4e 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -749,7 +749,7 @@
*Johannes Opper*
-* Introduce `ActiveRecord::TransactionSerializationError` for catching
+* Introduce new Active Record transaction error classes for catching
transaction serialization failures or deadlocks.
*Erol Fornoles*
diff --git a/activerecord/lib/active_record/associations/belongs_to_association.rb b/activerecord/lib/active_record/associations/belongs_to_association.rb
index 4a4f88bb94..a2432e389a 100644
--- a/activerecord/lib/active_record/associations/belongs_to_association.rb
+++ b/activerecord/lib/active_record/associations/belongs_to_association.rb
@@ -21,8 +21,8 @@ module ActiveRecord
self.target = record
end
- def default(record)
- writer(record) if reader.nil?
+ def default(&block)
+ writer(instance_exec(&block)) if reader.nil?
end
def reset
diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb
index 50a1c39ccf..2b9dd8aae8 100644
--- a/activerecord/lib/active_record/associations/builder/belongs_to.rb
+++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb
@@ -121,7 +121,7 @@ module ActiveRecord::Associations::Builder # :nodoc:
def self.add_default_callbacks(model, reflection)
model.before_validation lambda { |o|
- o.association(reflection.name).default o.instance_exec(&reflection.options[:default])
+ o.association(reflection.name).default(&reflection.options[:default])
}
end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
index e5a24b2aca..6019e05c4c 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
@@ -155,7 +155,11 @@ module ActiveRecord
private
def type_casted_binds(binds)
- binds.map { |attr| type_cast(attr.value_for_database) }
+ if binds.first.is_a?(Array)
+ binds.map { |column, value| type_cast(value, column) }
+ else
+ binds.map { |attr| type_cast(attr.value_for_database) }
+ end
end
def id_value_for_database(value)
diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb
index 070fca240f..601d575c0e 100644
--- a/activerecord/test/cases/adapter_test.rb
+++ b/activerecord/test/cases/adapter_test.rb
@@ -216,6 +216,15 @@ module ActiveRecord
assert result.is_a?(ActiveRecord::Result)
end
+ if ActiveRecord::Base.connection.prepared_statements
+ def test_select_all_with_legacy_binds
+ post = Post.create!(title: "foo", body: "bar")
+ expected = @connection.select_all("SELECT * FROM posts WHERE id = #{post.id}")
+ result = @connection.select_all("SELECT * FROM posts WHERE id = #{Arel::Nodes::BindParam.new.to_sql}", nil, [[nil, post.id]])
+ assert_equal expected.to_hash, result.to_hash
+ end
+ end
+
def test_select_methods_passing_a_association_relation
author = Author.create!(name: "john")
Post.create!(author: author, title: "foo", body: "bar")
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 969d36c303..d12cbc34dd 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,3 +1,10 @@
+* Fixed bug in `DateAndTime::Compatibility#to_time` that caused it to
+ raise `RuntimeError: can't modify frozen Time` when called on any frozen `Time`.
+ Properly pass through the frozen `Time` or `ActiveSupport::TimeWithZone` object
+ when calling `#to_time`.
+
+ *Kevin McPhillips* & *Andrew White*
+
* Remove implicit coercion deprecation of durations
In #28204 we deprecated implicit conversion of durations to a numeric which
@@ -208,13 +215,6 @@
## Rails 5.1.0.beta1 (February 23, 2017) ##
-* Fixed bug in `DateAndTime::Compatibility#to_time` that caused it to
- raise `RuntimeError: can't modify frozen Time` when called on any frozen `Time`.
- Properly pass through the frozen `Time` or `ActiveSupport::TimeWithZone` object
- when calling `#to_time`.
-
- *Kevin McPhillips* & *Andrew White*
-
* Cache `ActiveSupport::TimeWithZone#to_datetime` before freezing.
*Adam Rice*
diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md
index 6bd5321b92..5d4885d55c 100644
--- a/guides/source/5_1_release_notes.md
+++ b/guides/source/5_1_release_notes.md
@@ -34,51 +34,61 @@ Major Features
[Pull Request](https://github.com/rails/rails/pull/26836)
Rails 5.1 will allow managing JavaScript dependencies
-from NPM via Yarn.This will make it easy to use libraries like React, VueJS
+from NPM via Yarn. This will make it easy to use libraries like React, VueJS
or any other library from NPM world. The Yarn support is integrated with
the asset pipeline so that all dependencies will work seamlessly with the
Rails 5.1 app.
### Optional Webpack support
-Rails apps can use Webpack easily now using the [Webpacker](https://github.com/rails/webpacker)
-gem. New Rails 5.1 app can be generated using `--webpack` switch to enable Webpack integration.
+[Pull Request](https://github.com/rails/rails/pull/27288)
+
+Rails apps can integrate with [Webpack](https://webpack.js.org/), a JavaScript
+asset bundler, more easily using the new [Webpacker](https://github.com/rails/webpacker)
+gem. Use the `--webpack` flag when generating new applications to enable Webpack
+integration.
This is fully compatible with the asset pipeline, which you can continue to use for
-images, fonts, sounds, whatever. You can even have some JavaScript on the asset pipeline
-and some done via Webpack. It’s all managed via Yarn that’s on by default.
+images, fonts, sounds, and other assets. You can even have some JavaScript code
+managed by the asset pipeline, and other code processed via Webpack. All of this is managed
+by Yarn, which is enabled by default.
### jQuery no longer a default dependency
-jQuery was required by default in earlier versions of Rails to provide features like
-`data-remote`, `data-confirm` and other parts of Rails UJS. It is no longer required,
-as the `rails-ujs` is now written using plain vanilla JavaScript.
+[Pull Request](https://github.com/rails/rails/pull/27113)
+
+jQuery was required by default in earlier versions of Rails to provide features
+like `data-remote`, `data-confirm` and other parts of Rails' Unobtrusive JavaScript
+offerings. It is no longer required, as the UJS has been rewritten to use plain,
+vanilla JavaScript. This code now ships inside of Action View as
+`rails-ujs`.
-You can still use jQuery if needed, but it is no longer required by default.
+You can still use the jQuery version if needed, but it is no longer required by default.
### System tests
[Pull Request](https://github.com/rails/rails/pull/26703)
-Rails 5.1 has support for writing Capybara tests baked in in the form of
-System tests. Now you don't have to worry about configuring Capybara and
+Rails 5.1 has baked-in support for writing Capybara tests, in the form of
+System tests. You need no longer worry about configuring Capybara and
database cleaning strategies for such tests. Rails 5.1 provides a wrapper
-for running such tests in chrome with additional features such as failure
+for running tests in Chrome with additional features such as failure
screenshots.
### Encrypted secrets
[Pull Request](https://github.com/rails/rails/pull/28038)
-Rails will now allow management of application secrets in a secure way
-built on top of [sekrets](https://github.com/ahoward/sekrets) gem.
+Rails will now allow management of application secrets in a secure way,
+building on top of the [sekrets](https://github.com/ahoward/sekrets) gem.
-Run `bin/rails secrets:setup` to setup a new encrypted secrets file. It will
-generate a master key which needs to be stored outside of the repository and it will
-allow checking in the actual secrets in the revision control.
+Run `bin/rails secrets:setup` to setup a new encrypted secrets file. This will
+also generate a master key, which must be stored outside of the repository. The
+secrets themselves can then be safely checked into the revision control system,
+in an encrypted form.
-The secrets will be decrypted in production either using `RAILS_MASTER_KEY` from
-the ENV or injected key file.
+Secrets will be decrypted in production, using a key stored either in the
+`RAILS_MASTER_KEY` environment variable, or in a key file.
### Parameterized mailers
@@ -112,7 +122,7 @@ InvitationsMailer.with(inviter: person_a, invitee: person_b).account_invitation.
[Pull Request](https://github.com/rails/rails/pull/23138)
-Rails 5.1 has added two new methods - `resolve` and `direct` to the routing
+Rails 5.1 has added two new methods, `resolve` and `direct`, to the routing
DSL.
The `resolve` method allows customizing polymorphic mapping of models.
@@ -129,7 +139,7 @@ resolve("Basket") { [:basket] }
<% end %>
```
-This will generate the singular URL `/basket` instead of usual `/baskets/:id`.
+This will generate the singular URL `/basket` instead of the usual `/baskets/:id`.
The `direct` method allows creation of custom URL helpers.
@@ -141,8 +151,8 @@ direct(:homepage) { "http://www.rubyonrails.org" }
```
The return value of the block must be a valid argument for the `url_for`
-method. So you can pass a valid string URL, or a hash, or an array, or an
-Active Model instance or an Active Model class.
+method. So, you can pass a valid string URL, Hash, Array, an
+Active Model instance, or an Active Model class.
``` ruby
direct :commentable do |model|
@@ -158,10 +168,10 @@ end
[Pull Request](https://github.com/rails/rails/pull/26976)
-Before Rails 5.1, there were two interfaces for handling HTML forms,
+Before Rails 5.1, there were two interfaces for handling HTML forms:
`form_for` for model instances and `form_tag` for custom URLs.
-Rails 5.1 combines both of these interfaces with `form_with` and
+Rails 5.1 combines both of these interfaces with `form_with`, and
can generate form tags based on URLs, scopes or models.
``` erb
diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md
index 380fdac658..9673571909 100644
--- a/guides/source/action_mailer_basics.md
+++ b/guides/source/action_mailer_basics.md
@@ -550,8 +550,9 @@ url helper.
<%= user_url(@user, host: 'example.com') %>
```
-NOTE: non-`GET` links require [jQuery UJS](https://github.com/rails/jquery-ujs)
-and won't work in mailer templates. They will result in normal `GET` requests.
+NOTE: non-`GET` links require [rails-ujs](https://github.com/rails/rails-ujs) or
+[jQuery UJS](https://github.com/rails/jquery-ujs), and won't work in mailer templates.
+They will result in normal `GET` requests.
### Adding images in Action Mailer Views
diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md
index c65d1e6de5..b58ca61848 100644
--- a/guides/source/active_job_basics.md
+++ b/guides/source/active_job_basics.md
@@ -114,7 +114,7 @@ For enqueuing and executing jobs in production you need to set up a queuing back
that is to say you need to decide for a 3rd-party queuing library that Rails should use.
Rails itself only provides an in-process queuing system, which only keeps the jobs in RAM.
If the process crashes or the machine is reset, then all outstanding jobs are lost with the
-default async back-end. This may be fine for smaller apps or non-critical jobs, but most
+default async backend. This may be fine for smaller apps or non-critical jobs, but most
production apps will need to pick a persistent backend.
### Backends
diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md
index fd7626250c..af4ef6a58d 100644
--- a/guides/source/caching_with_rails.md
+++ b/guides/source/caching_with_rails.md
@@ -396,7 +396,7 @@ config.cache_store = :file_store, "/path/to/cache/directory"
```
With this cache store, multiple server processes on the same host can share a
-cache. The cache store is appropriate for low to medium traffic sites that are
+cache. This cache store is appropriate for low to medium traffic sites that are
served off one or two hosts. Server processes running on different hosts could
share a cache by using a shared file system, but that setup is not recommended.
@@ -570,6 +570,20 @@ You can also set the strong ETag directly on the response.
response.strong_etag = response.body # => "618bbc92e2d35ea1945008b42799b0e7"
```
+Caching in Development
+----------------------
+
+It's common to want to test the caching strategy of your application
+in developement mode. Rails provides the rake task `dev:cache` to
+easily toggle caching on/off.
+
+```bash
+$ bin/rails dev:cache
+Development mode is now being cached.
+$ bin/rails dev:cache
+Development mode is no longer being cached.
+```
+
References
----------
diff --git a/guides/source/security.md b/guides/source/security.md
index a57c6ea247..a14134f8c1 100644
--- a/guides/source/security.md
+++ b/guides/source/security.md
@@ -257,13 +257,12 @@ protect_from_forgery with: :exception
This will automatically include a security token in all forms and Ajax requests generated by Rails. If the security token doesn't match what was expected, an exception will be thrown.
-NOTE: By default, Rails includes jQuery and an [unobtrusive scripting adapter for
-jQuery](https://github.com/rails/jquery-ujs), which adds a header called
-`X-CSRF-Token` on every non-GET Ajax call made by jQuery with the security token.
-Without this header, non-GET Ajax requests won't be accepted by Rails. When using
-another library to make Ajax calls, it is necessary to add the security token as
-a default header for Ajax calls in your library. To get the token, have a look at
-`<meta name='csrf-token' content='THE-TOKEN'>` tag printed by
+NOTE: By default, Rails includes an [unobtrusive scripting adapter](https://github.com/rails/rails-ujs),
+which adds a header called `X-CSRF-Token` with the security token on every non-GET
+Ajax call. Without this header, non-GET Ajax requests won't be accepted by Rails.
+When using another library to make Ajax calls, it is necessary to add the security
+token as a default header for Ajax calls in your library. To get the token, have
+a look at `<meta name='csrf-token' content='THE-TOKEN'>` tag printed by
`<%= csrf_meta_tags %>` in your application view.
It is common to use persistent cookies to store user information, with `cookies.permanent` for example. In this case, the cookies will not be cleared and the out of the box CSRF protection will not be effective. If you are using a different cookie store than the session for this information, you must handle what to do with it yourself:
diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md
index c1dfcab6f3..e04b3e3581 100644
--- a/guides/source/working_with_javascript_in_rails.md
+++ b/guides/source/working_with_javascript_in_rails.md
@@ -149,7 +149,7 @@ Because of Unobtrusive JavaScript, the Rails "Ajax helpers" are actually in two
parts: the JavaScript half and the Ruby half.
Unless you have disabled the Asset Pipeline,
-[rails.js](https://github.com/rails/jquery-ujs/blob/master/src/rails.js)
+[rails-ujs](https://github.com/rails/rails-ujs/blob/master/src/rails-ujs.coffee)
provides the JavaScript half, and the regular Ruby view helpers add appropriate
tags to your DOM.
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index b0592151b7..819e801740 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -55,6 +55,34 @@ module Rails
@read_encrypted_secrets = false
end
+ def load_defaults(target_version)
+ case target_version.to_s
+ when "5.0"
+ if respond_to?(:action_controller)
+ action_controller.per_form_csrf_tokens = true
+ action_controller.forgery_protection_origin_check = true
+ end
+
+ ActiveSupport.to_time_preserves_timezone = true
+
+ if respond_to?(:active_record)
+ active_record.belongs_to_required_by_default = true
+ end
+
+ self.ssl_options = { hsts: { subdomains: true } }
+
+ when "5.1"
+ load_defaults "5.0"
+
+ if respond_to?(:assets)
+ assets.unknown_asset_fallback = false
+ end
+
+ else
+ raise "Unknown version #{target_version.to_s.inspect}"
+ end
+ end
+
def encoding=(value)
@encoding = value
silence_warnings do
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index 442258c9d1..38830ba38f 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -371,6 +371,14 @@ module Rails
end
end
+ def delete_new_framework_defaults
+ # Sprockets owns the only new default for 5.1: if it's disabled,
+ # we don't want the file.
+ unless options[:update] && !options[:skip_sprockets]
+ remove_file "config/initializers/new_framework_defaults_5_1.rb"
+ end
+ end
+
def delete_bin_yarn_if_skip_yarn_option
remove_file "bin/yarn" if options[:skip_yarn]
end
diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb
index c0a0bd0a3e..d5d214052f 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/application.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -22,6 +22,9 @@ Bundler.require(*Rails.groups)
module <%= app_const_base %>
class Application < Rails::Application
+ # Initialize configuration defaults for originally generated Rails version.
+ config.load_defaults <%= Rails::VERSION::STRING.to_f %>
+
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt
deleted file mode 100644
index bd844f0503..0000000000
--- a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Be sure to restart your server when you modify this file.
-#
-# This file contains migration options to ease your Rails 5.0 upgrade.
-#
-<%- if options[:update] -%>
-# Once upgraded flip defaults one by one to migrate to the new default.
-#
-<%- end -%>
-# Read the Guide for Upgrading Ruby on Rails for more info on each option.
-<%- unless options[:api] -%>
-
-# Enable per-form CSRF tokens. Previous versions had false.
-Rails.application.config.action_controller.per_form_csrf_tokens = <%= options[:update] ? false : true %>
-
-# Enable origin-checking CSRF mitigation. Previous versions had false.
-Rails.application.config.action_controller.forgery_protection_origin_check = <%= options[:update] ? false : true %>
-<%- end -%>
-
-# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
-# Previous versions had false.
-ActiveSupport.to_time_preserves_timezone = <%= options[:update] ? false : true %>
-<%- unless options[:skip_active_record] -%>
-
-# Require `belongs_to` associations by default. Previous versions had false.
-Rails.application.config.active_record.belongs_to_required_by_default = <%= options[:update] ? false : true %>
-<%- end -%>
-<%- unless options[:update] -%>
-
-# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
-Rails.application.config.ssl_options = { hsts: { subdomains: true } }
-<%- end -%>
-<%- unless options[:skip_sprockets] -%>
-
-# Unknown asset fallback will return the path passed in when the given
-# asset is not present in the asset pipeline.
-Rails.application.config.assets.unknown_asset_fallback = <%= options[:update] ? true : false %>
-<%- end -%>
diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt
new file mode 100644
index 0000000000..5f5545c4c7
--- /dev/null
+++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt
@@ -0,0 +1,13 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains migration options to ease your Rails 5.1 upgrade.
+#
+# Once upgraded flip defaults one by one to migrate to the new default.
+#
+# Read the Guide for Upgrading Ruby on Rails for more info on each option.
+<%- unless options[:skip_sprockets] -%>
+
+# Unknown asset fallback will return the path passed in when the given
+# asset is not present in the asset pipeline.
+# Rails.application.config.assets.unknown_asset_fallback = false
+<%- end -%>
diff --git a/railties/test/generators/api_app_generator_test.rb b/railties/test/generators/api_app_generator_test.rb
index bdef1798f8..bb8b29501a 100644
--- a/railties/test/generators/api_app_generator_test.rb
+++ b/railties/test/generators/api_app_generator_test.rb
@@ -61,15 +61,6 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase
end
end
- def test_generator_skips_per_form_csrf_token_and_origin_check_configs_for_api_apps
- run_generator
-
- assert_file "config/initializers/new_framework_defaults.rb" do |initializer_content|
- assert_no_match(/per_form_csrf_tokens/, initializer_content)
- assert_no_match(/forgery_protection_origin_check/, initializer_content)
- end
- end
-
private
def default_files
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 79fe4e4eb7..ac43e8d22d 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -156,6 +156,22 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_no_file "config/initializers/cors.rb"
end
+ def test_new_application_doesnt_need_defaults
+ assert_no_file "config/initializers/new_framework_defaults_5_1.rb"
+ end
+
+ def test_new_application_load_defaults
+ app_root = File.join(destination_root, "myfirstapp")
+ run_generator [app_root]
+ output = nil
+
+ Dir.chdir(app_root) do
+ output = `./bin/rails r "puts Rails.application.config.assets.unknown_asset_fallback"`
+ end
+
+ assert_equal "false\n", output
+ end
+
def test_app_update_keep_the_cookie_serializer_if_it_is_already_configured
app_root = File.join(destination_root, "myapp")
run_generator [app_root]
@@ -197,21 +213,18 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
end
- def test_app_update_does_not_create_new_framework_defaults_by_default
+ def test_app_update_create_new_framework_defaults
app_root = File.join(destination_root, "myapp")
run_generator [app_root]
- FileUtils.rm("#{app_root}/config/initializers/new_framework_defaults.rb")
+ assert_no_file "#{app_root}/config/initializers/new_framework_defaults_5_1.rb"
stub_rails_application(app_root) do
generator = Rails::Generators::AppGenerator.new ["rails"], { update: true }, destination_root: app_root, shell: @shell
generator.send(:app_const)
quietly { generator.send(:update_config_files) }
- assert_file "#{app_root}/config/initializers/new_framework_defaults.rb" do |content|
- assert_match(/Rails\.application\.config.active_record\.belongs_to_required_by_default = false/, content)
- assert_no_match(/Rails\.application\.config\.ssl_options/, content)
- end
+ assert_file "#{app_root}/config/initializers/new_framework_defaults_5_1.rb"
end
end
@@ -367,10 +380,6 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_file "bin/update" do |update_content|
assert_no_match(/db:migrate/, update_content)
end
-
- assert_file "config/initializers/new_framework_defaults.rb" do |initializer_content|
- assert_no_match(/belongs_to_required_by_default/, initializer_content)
- end
end
def test_generator_if_skip_action_mailer_is_given
@@ -415,9 +424,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_no_match(/config\.assets\.js_compressor = :uglifier/, content)
assert_no_match(/config\.assets\.css_compressor = :sass/, content)
end
- assert_file "config/initializers/new_framework_defaults.rb" do |content|
- assert_no_match(/unknown_asset_fallback/, content)
- end
+ assert_no_file "config/initializers/new_framework_defaults_5_1.rb"
end
def test_generator_if_skip_yarn_is_given
diff --git a/railties/test/generators/encrypted_secrets_generator_test.rb b/railties/test/generators/encrypted_secrets_generator_test.rb
index 747abf19ed..21fdcab19f 100644
--- a/railties/test/generators/encrypted_secrets_generator_test.rb
+++ b/railties/test/generators/encrypted_secrets_generator_test.rb
@@ -12,11 +12,11 @@ class EncryptedSecretsGeneratorTest < Rails::Generators::TestCase
def test_generates_key_file_and_encrypted_secrets_file
run_generator
- assert_file "config/secrets.yml.key", /[\w\d]+/
+ assert_file "config/secrets.yml.key", /\w+/
assert File.exist?("config/secrets.yml.enc")
- assert_no_match(/production:\n# external_api_key: [\w\d]+/, IO.binread("config/secrets.yml.enc"))
- assert_match(/production:\n# external_api_key: [\w\d]+/, Rails::Secrets.read)
+ assert_no_match(/production:\n# external_api_key: \w+/, IO.binread("config/secrets.yml.enc"))
+ assert_match(/production:\n# external_api_key: \w+/, Rails::Secrets.read)
end
def test_appends_to_gitignore
diff --git a/railties/test/railties/mounted_engine_test.rb b/railties/test/railties/mounted_engine_test.rb
index 5838d0d7e7..6639e55382 100644
--- a/railties/test/railties/mounted_engine_test.rb
+++ b/railties/test/railties/mounted_engine_test.rb
@@ -141,7 +141,7 @@ module ApplicationTests
end
def engine_asset_path
- render inline: "<%= asset_path 'images/foo.png' %>"
+ render inline: "<%= asset_path 'images/foo.png', skip_pipeline: true %>"
end
end
end