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/relation/delegation.rb2
-rw-r--r--guides/source/5_1_release_notes.md28
-rw-r--r--guides/source/active_job_basics.md2
-rw-r--r--railties/lib/rails/application/configuration.rb6
-rw-r--r--railties/test/generators/app_generator_test.rb12
-rw-r--r--railties/test/railties/mounted_engine_test.rb2
9 files changed, 37 insertions, 23 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/relation/delegation.rb b/activerecord/lib/active_record/relation/delegation.rb
index 0612151584..7b704c7e66 100644
--- a/activerecord/lib/active_record/relation/delegation.rb
+++ b/activerecord/lib/active_record/relation/delegation.rb
@@ -36,7 +36,7 @@ module ActiveRecord
# may vary depending on the klass of a relation, so we create a subclass of Relation
# for each different klass, and the delegations are compiled into that subclass only.
- delegate :to_xml, :encode_with, :length, :collect, :map, :each, :all?, :include?, :to_ary, :join,
+ delegate :to_xml, :encode_with, :length, :collect, :uniq, :each, :all?, :include?, :to_ary, :join,
:[], :&, :|, :+, :-, :sample, :reverse, :compact, :in_groups, :in_groups_of,
:to_sentence, :to_formatted_s, :as_json,
:shuffle, :split, :index, to: :records
diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md
index 0216f04761..5d4885d55c 100644
--- a/guides/source/5_1_release_notes.md
+++ b/guides/source/5_1_release_notes.md
@@ -34,7 +34,7 @@ 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.
@@ -50,7 +50,8 @@ integration.
This is fully compatible with the asset pipeline, which you can continue to use for
images, fonts, sounds, and other assets. You can even have some JavaScript code
-managed by the asset pipeline, and other code processed via Webpack. It’s all managed via Yarn that’s on by default.
+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
@@ -62,14 +63,14 @@ 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 version 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 tests in Chrome with additional features such as failure
screenshots.
@@ -78,15 +79,16 @@ screenshots.
[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 the [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 using either the `RAILS_MASTER_KEY`
-environment variable from a 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
@@ -149,7 +151,7 @@ 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, Hash, array, an
+method. So, you can pass a valid string URL, Hash, Array, an
Active Model instance, or an Active Model class.
``` ruby
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/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 027207bbb2..819e801740 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -58,14 +58,14 @@ module Rails
def load_defaults(target_version)
case target_version.to_s
when "5.0"
- if defined?(action_controller)
+ 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 defined?(active_record)
+ if respond_to?(:active_record)
active_record.belongs_to_required_by_default = true
end
@@ -74,7 +74,7 @@ module Rails
when "5.1"
load_defaults "5.0"
- if defined?(assets)
+ if respond_to?(:assets)
assets.unknown_asset_fallback = false
end
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 281376cdee..ac43e8d22d 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -160,6 +160,18 @@ class AppGeneratorTest < Rails::Generators::TestCase
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]
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