aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG.md6
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb2
-rw-r--r--actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb14
-rw-r--r--actionpack/test/dispatch/system_testing/screenshot_helper_test.rb32
-rw-r--r--actionview/lib/action_view/helpers/active_model_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/asset_url_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/atom_feed_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/cache_helper.rb10
-rw-r--r--actionview/lib/action_view/helpers/capture_helper.rb14
-rw-r--r--actionview/lib/action_view/helpers/controller_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/csrf_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/date_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/debug_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/form_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/form_options_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/form_tag_helper.rb4
-rw-r--r--actionview/lib/action_view/helpers/javascript_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/record_tag_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/rendering_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/sanitize_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/tags.rb2
-rw-r--r--actionview/lib/action_view/helpers/translation_helper.rb2
-rw-r--r--actionview/lib/action_view/renderer/partial_renderer.rb20
-rw-r--r--actionview/lib/action_view/template/handlers.rb2
-rw-r--r--actionview/lib/action_view/template/html.rb2
-rw-r--r--actionview/lib/action_view/template/resolver.rb6
-rw-r--r--actionview/lib/action_view/template/text.rb2
-rw-r--r--actionview/lib/action_view/template/types.rb2
-rw-r--r--activemodel/lib/active_model/callbacks.rb4
-rw-r--r--activerecord/lib/active_record/attribute_methods/dirty.rb22
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb2
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb2
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb4
-rw-r--r--activerecord/lib/active_record/define_callbacks.rb6
-rw-r--r--activerecord/lib/active_record/fixtures.rb2
-rw-r--r--activerecord/lib/active_record/no_touching.rb2
-rw-r--r--activerecord/lib/active_record/persistence.rb4
-rw-r--r--activerecord/lib/active_record/reflection.rb16
-rw-r--r--activerecord/lib/active_record/relation/delegation.rb8
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb3
-rw-r--r--activerecord/test/cases/adapters/mysql2/table_options_test.rb8
-rw-r--r--activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb2
-rw-r--r--activerecord/test/cases/autosave_association_test.rb17
-rw-r--r--activerecord/test/cases/comment_test.rb2
-rw-r--r--activerecord/test/cases/primary_keys_test.rb6
-rw-r--r--activerecord/test/cases/relation/delegation_test.rb1
-rw-r--r--activerecord/test/cases/schema_dumper_test.rb13
-rw-r--r--activestorage/app/jobs/active_storage/purge_job.rb6
-rw-r--r--activestorage/app/models/active_storage/attachment.rb10
-rw-r--r--activestorage/lib/active_storage/service/disk_service.rb2
-rw-r--r--activestorage/test/service/disk_service_test.rb2
-rw-r--r--activesupport/lib/active_support/dependencies.rb2
-rw-r--r--guides/source/5_0_release_notes.md4
-rw-r--r--guides/source/action_mailer_basics.md5
-rw-r--r--guides/source/active_record_querying.md2
-rw-r--r--guides/source/active_support_core_extensions.md4
-rw-r--r--guides/source/caching_with_rails.md6
-rw-r--r--guides/source/kindle/toc.html.erb2
-rw-r--r--guides/source/working_with_javascript_in_rails.md12
-rw-r--r--railties/lib/rails/api/generator.rb9
-rw-r--r--railties/lib/rails/application/configuration.rb2
-rw-r--r--railties/lib/rails/command/actions.rb6
-rw-r--r--railties/lib/rails/command/base.rb4
-rw-r--r--railties/lib/rails/secrets.rb2
-rw-r--r--railties/test/generators/encrypted_secrets_generator_test.rb4
-rw-r--r--railties/test/secrets_test.rb4
66 files changed, 189 insertions, 169 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 938b24a6b9..b56a1c5d4b 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,3 +1,9 @@
+* Make `take_failed_screenshot` work within engine.
+
+ Fixes #30405.
+
+ *Yuji Yaginuma*
+
* Deprecate `ActionDispatch::TestResponse` response aliases
`#success?`, `#missing?` & `#error?` are not supported by the actual
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 57a5bc681e..2b43ade081 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -473,7 +473,7 @@ module ActionDispatch
# <tt>params[<:param>]</tt>.
# In your router:
#
- # resources :user, param: :name
+ # resources :users, param: :name
#
# You can override <tt>ActiveRecord::Base#to_param</tt> of a related
# model to construct a URL:
diff --git a/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb b/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
index 7efdeb4e7b..6c337cdc31 100644
--- a/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
+++ b/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
@@ -44,11 +44,15 @@ module ActionDispatch
end
def image_path
- "tmp/screenshots/#{image_name}.png"
+ @image_path ||= absolute_image_path.relative_path_from(Pathname.pwd).to_s
+ end
+
+ def absolute_image_path
+ Rails.root.join("tmp/screenshots/#{image_name}.png")
end
def save_image
- page.save_screenshot(Rails.root.join(image_path))
+ page.save_screenshot(absolute_image_path)
end
def output_type
@@ -69,10 +73,10 @@ module ActionDispatch
case output_type
when "artifact"
- message << "\e]1338;url=artifact://#{image_path}\a\n"
+ message << "\e]1338;url=artifact://#{absolute_image_path}\a\n"
when "inline"
- name = inline_base64(File.basename(image_path))
- image = inline_base64(File.read(image_path))
+ name = inline_base64(File.basename(absolute_image_path))
+ image = inline_base64(File.read(absolute_image_path))
message << "\e]1337;File=name=#{name};height=400px;inline=1:#{image}\a\n"
end
diff --git a/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb b/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb
index 4b49a42317..2afda31cf5 100644
--- a/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb
+++ b/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb
@@ -8,23 +8,29 @@ class ScreenshotHelperTest < ActiveSupport::TestCase
test "image path is saved in tmp directory" do
new_test = DrivenBySeleniumWithChrome.new("x")
- assert_equal "tmp/screenshots/x.png", new_test.send(:image_path)
+ Rails.stub :root, Pathname.getwd do
+ assert_equal "tmp/screenshots/x.png", new_test.send(:image_path)
+ end
end
test "image path includes failures text if test did not pass" do
new_test = DrivenBySeleniumWithChrome.new("x")
- new_test.stub :passed?, false do
- assert_equal "tmp/screenshots/failures_x.png", new_test.send(:image_path)
+ Rails.stub :root, Pathname.getwd do
+ new_test.stub :passed?, false do
+ assert_equal "tmp/screenshots/failures_x.png", new_test.send(:image_path)
+ end
end
end
test "image path does not include failures text if test skipped" do
new_test = DrivenBySeleniumWithChrome.new("x")
- new_test.stub :passed?, false do
- new_test.stub :skipped?, true do
- assert_equal "tmp/screenshots/x.png", new_test.send(:image_path)
+ Rails.stub :root, Pathname.getwd do
+ new_test.stub :passed?, false do
+ new_test.stub :skipped?, true do
+ assert_equal "tmp/screenshots/x.png", new_test.send(:image_path)
+ end
end
end
end
@@ -36,13 +42,23 @@ class ScreenshotHelperTest < ActiveSupport::TestCase
new_test = DrivenBySeleniumWithChrome.new("x")
- new_test.stub :passed?, false do
- assert_match "\e]1338;url=artifact://tmp/screenshots/failures_x.png\a", new_test.send(:display_image)
+ Rails.stub :root, Pathname.getwd do
+ new_test.stub :passed?, false do
+ assert_match %r|url=artifact://.+?tmp/screenshots/failures_x\.png|, new_test.send(:display_image)
+ end
end
ensure
ENV["RAILS_SYSTEM_TESTING_SCREENSHOT"] = original_output_type
end
end
+
+ test "image path returns the relative path from current directory" do
+ new_test = DrivenBySeleniumWithChrome.new("x")
+
+ Rails.stub :root, Pathname.getwd.join("..") do
+ assert_equal "../tmp/screenshots/x.png", new_test.send(:image_path)
+ end
+ end
end
class RackTestScreenshotsTest < DrivenByRackTest
diff --git a/actionview/lib/action_view/helpers/active_model_helper.rb b/actionview/lib/action_view/helpers/active_model_helper.rb
index 46b514012c..f1ef715710 100644
--- a/actionview/lib/action_view/helpers/active_model_helper.rb
+++ b/actionview/lib/action_view/helpers/active_model_helper.rb
@@ -5,7 +5,7 @@ require "active_support/core_ext/enumerable"
module ActionView
# = Active Model Helpers
- module Helpers
+ module Helpers #:nodoc:
module ActiveModelHelper
end
diff --git a/actionview/lib/action_view/helpers/asset_url_helper.rb b/actionview/lib/action_view/helpers/asset_url_helper.rb
index 5ba2370efe..a4dcfc9a6c 100644
--- a/actionview/lib/action_view/helpers/asset_url_helper.rb
+++ b/actionview/lib/action_view/helpers/asset_url_helper.rb
@@ -4,7 +4,7 @@ require "zlib"
module ActionView
# = Action View Asset URL Helpers
- module Helpers
+ module Helpers #:nodoc:
# This module provides methods for generating asset paths and
# urls.
#
diff --git a/actionview/lib/action_view/helpers/atom_feed_helper.rb b/actionview/lib/action_view/helpers/atom_feed_helper.rb
index 34245b5df5..e6b9878271 100644
--- a/actionview/lib/action_view/helpers/atom_feed_helper.rb
+++ b/actionview/lib/action_view/helpers/atom_feed_helper.rb
@@ -4,7 +4,7 @@ require "set"
module ActionView
# = Action View Atom Feed Helpers
- module Helpers
+ module Helpers #:nodoc:
module AtomFeedHelper
# Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on ERB or any other
# template languages).
diff --git a/actionview/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb
index cd213ad6a2..3cbb1ed1a7 100644
--- a/actionview/lib/action_view/helpers/cache_helper.rb
+++ b/actionview/lib/action_view/helpers/cache_helper.rb
@@ -2,7 +2,7 @@
module ActionView
# = Action View Cache Helper
- module Helpers
+ module Helpers #:nodoc:
module CacheHelper
# This helper exposes a method for caching fragments of a view
# rather than an entire action or page. This technique is useful
@@ -111,9 +111,9 @@ module ActionView
# <%= render_categorizable_events @person.events %>
#
# This marks every template in the directory as a dependency. To find those
- # templates, the wildcard path must be absolutely defined from app/views or paths
+ # templates, the wildcard path must be absolutely defined from <tt>app/views</tt> or paths
# otherwise added with +prepend_view_path+ or +append_view_path+.
- # This way the wildcard for `app/views/recordings/events` would be `recordings/events/*` etc.
+ # This way the wildcard for <tt>app/views/recordings/events</tt> would be <tt>recordings/events/*</tt> etc.
#
# The pattern used to match explicit dependencies is <tt>/# Template Dependency: (\S+)/</tt>,
# so it's important that you type it out just so.
@@ -133,14 +133,14 @@ module ActionView
#
# === Collection Caching
#
- # When rendering a collection of objects that each use the same partial, a `cached`
+ # When rendering a collection of objects that each use the same partial, a <tt>:cached</tt>
# option can be passed.
#
# For collections rendered such:
#
# <%= render partial: 'projects/project', collection: @projects, cached: true %>
#
- # The `cached: true` will make Action View's rendering read several templates
+ # The <tt>cached: true</tt> will make Action View's rendering read several templates
# from cache at once instead of one call per template.
#
# Templates in the collection not already cached are written to cache.
diff --git a/actionview/lib/action_view/helpers/capture_helper.rb b/actionview/lib/action_view/helpers/capture_helper.rb
index 690ce6a0ee..92f7ddb70d 100644
--- a/actionview/lib/action_view/helpers/capture_helper.rb
+++ b/actionview/lib/action_view/helpers/capture_helper.rb
@@ -4,12 +4,12 @@ require "active_support/core_ext/string/output_safety"
module ActionView
# = Action View Capture Helper
- module Helpers
+ module Helpers #:nodoc:
# CaptureHelper exposes methods to let you extract generated markup which
# can be used in other parts of a template or layout file.
#
# It provides a method to capture blocks into variables through capture and
- # a way to capture a block of markup for use in a layout through content_for.
+ # a way to capture a block of markup for use in a layout through {content_for}[rdoc-ref:ActionView::Helpers::CaptureHelper#content_for].
module CaptureHelper
# The capture method extracts part of a template as a String object.
# You can then use this object anywhere in your templates, layout, or helpers.
@@ -44,7 +44,7 @@ module ActionView
end
end
- # Calling content_for stores a block of markup in an identifier for later use.
+ # Calling <tt>content_for</tt> stores a block of markup in an identifier for later use.
# In order to access this stored content in other templates, helper modules
# or the layout, you would pass the identifier as an argument to <tt>content_for</tt>.
#
@@ -110,7 +110,7 @@ module ActionView
# That will place +script+ tags for your default set of JavaScript files on the page;
# this technique is useful if you'll only be using these scripts in a few views.
#
- # Note that content_for concatenates (default) the blocks it is given for a particular
+ # Note that <tt>content_for</tt> concatenates (default) the blocks it is given for a particular
# identifier in order. For example:
#
# <% content_for :navigation do %>
@@ -127,7 +127,7 @@ module ActionView
#
# <ul><%= content_for :navigation %></ul>
#
- # If the flush parameter is true content_for replaces the blocks it is given. For example:
+ # If the flush parameter is +true+ <tt>content_for</tt> replaces the blocks it is given. For example:
#
# <% content_for :navigation do %>
# <li><%= link_to 'Home', action: 'index' %></li>
@@ -147,7 +147,7 @@ module ActionView
#
# <% content_for :script, javascript_include_tag(:defaults) %>
#
- # WARNING: content_for is ignored in caches. So you shouldn't use it for elements that will be fragment cached.
+ # WARNING: <tt>content_for</tt> is ignored in caches. So you shouldn't use it for elements that will be fragment cached.
def content_for(name, content = nil, options = {}, &block)
if content || block_given?
if block_given?
@@ -174,7 +174,7 @@ module ActionView
result unless content
end
- # content_for? checks whether any content has been captured yet using `content_for`.
+ # <tt>content_for?</tt> checks whether any content has been captured yet using <tt>content_for</tt>.
# Useful to render parts of your layout differently based on what is in your views.
#
# <%# This is the layout %>
diff --git a/actionview/lib/action_view/helpers/controller_helper.rb b/actionview/lib/action_view/helpers/controller_helper.rb
index 00d8b9665d..79cf86c7d1 100644
--- a/actionview/lib/action_view/helpers/controller_helper.rb
+++ b/actionview/lib/action_view/helpers/controller_helper.rb
@@ -3,7 +3,7 @@
require "active_support/core_ext/module/attr_internal"
module ActionView
- module Helpers
+ module Helpers #:nodoc:
# This module keeps all methods and behavior in ActionView
# that simply delegates to the controller.
module ControllerHelper #:nodoc:
diff --git a/actionview/lib/action_view/helpers/csrf_helper.rb b/actionview/lib/action_view/helpers/csrf_helper.rb
index d1b83f87d3..69c59844a6 100644
--- a/actionview/lib/action_view/helpers/csrf_helper.rb
+++ b/actionview/lib/action_view/helpers/csrf_helper.rb
@@ -2,7 +2,7 @@
module ActionView
# = Action View CSRF Helper
- module Helpers
+ module Helpers #:nodoc:
module CsrfHelper
# Returns meta tags "csrf-param" and "csrf-token" with the name of the cross-site
# request forgery protection parameter and token, respectively.
diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb
index 339d582f76..642bd0fec6 100644
--- a/actionview/lib/action_view/helpers/date_helper.rb
+++ b/actionview/lib/action_view/helpers/date_helper.rb
@@ -9,7 +9,7 @@ require "active_support/core_ext/object/acts_like"
require "active_support/core_ext/object/with_options"
module ActionView
- module Helpers
+ module Helpers #:nodoc:
# = Action View Date Helpers
#
# The Date Helper primarily creates select/option tags for different kinds of dates and times or date and time
diff --git a/actionview/lib/action_view/helpers/debug_helper.rb b/actionview/lib/action_view/helpers/debug_helper.rb
index 232d688077..52dff1f750 100644
--- a/actionview/lib/action_view/helpers/debug_helper.rb
+++ b/actionview/lib/action_view/helpers/debug_helper.rb
@@ -4,7 +4,7 @@ module ActionView
# = Action View Debug Helper
#
# Provides a set of methods for making it easier to debug Rails objects.
- module Helpers
+ module Helpers #:nodoc:
module DebugHelper
include TagHelper
diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb
index bcda066837..6702c65ccb 100644
--- a/actionview/lib/action_view/helpers/form_helper.rb
+++ b/actionview/lib/action_view/helpers/form_helper.rb
@@ -14,7 +14,7 @@ require "active_support/core_ext/string/inflections"
module ActionView
# = Action View Form Helpers
- module Helpers
+ module Helpers #:nodoc:
# Form helpers are designed to make working with resources much easier
# compared to using vanilla HTML.
#
diff --git a/actionview/lib/action_view/helpers/form_options_helper.rb b/actionview/lib/action_view/helpers/form_options_helper.rb
index 0f1a452652..1517abfad0 100644
--- a/actionview/lib/action_view/helpers/form_options_helper.rb
+++ b/actionview/lib/action_view/helpers/form_options_helper.rb
@@ -9,7 +9,7 @@ require "active_support/core_ext/array/wrap"
module ActionView
# = Action View Form Option Helpers
- module Helpers
+ module Helpers #:nodoc:
# Provides a number of methods for turning different kinds of containers into a set of option tags.
#
# The <tt>collection_select</tt>, <tt>select</tt> and <tt>time_zone_select</tt> methods take an <tt>options</tt> parameter, a hash:
diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb
index 14cbed24b0..31a1f8be8c 100644
--- a/actionview/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/form_tag_helper.rb
@@ -7,7 +7,7 @@ require "active_support/core_ext/module/attribute_accessors"
module ActionView
# = Action View Form Tag Helpers
- module Helpers
+ module Helpers #:nodoc:
# Provides a number of methods for creating form tags that don't rely on an Active Record object assigned to the template like
# FormHelper does. Instead, you provide the names and values manually.
#
@@ -456,7 +456,7 @@ module ActionView
# submit tag but it isn't supported in legacy browsers. However,
# the button tag does allow for richer labels such as images and emphasis,
# so this helper will also accept a block. By default, it will create
- # a button tag with type `submit`, if type is not given.
+ # a button tag with type <tt>submit</tt>, if type is not given.
#
# ==== Options
# * <tt>:data</tt> - This option can be used to add custom data attributes.
diff --git a/actionview/lib/action_view/helpers/javascript_helper.rb b/actionview/lib/action_view/helpers/javascript_helper.rb
index cce7c1dcfd..11eefe0ee0 100644
--- a/actionview/lib/action_view/helpers/javascript_helper.rb
+++ b/actionview/lib/action_view/helpers/javascript_helper.rb
@@ -3,7 +3,7 @@
require_relative "tag_helper"
module ActionView
- module Helpers
+ module Helpers #:nodoc:
module JavaScriptHelper
JS_ESCAPE_MAP = {
'\\' => '\\\\',
diff --git a/actionview/lib/action_view/helpers/record_tag_helper.rb b/actionview/lib/action_view/helpers/record_tag_helper.rb
index 4303de4209..a6953ee905 100644
--- a/actionview/lib/action_view/helpers/record_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/record_tag_helper.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module ActionView
- module Helpers
+ module Helpers #:nodoc:
module RecordTagHelper
def div_for(*) # :nodoc:
raise NoMethodError, "The `div_for` method has been removed from " \
diff --git a/actionview/lib/action_view/helpers/rendering_helper.rb b/actionview/lib/action_view/helpers/rendering_helper.rb
index 2702fa28b2..8e505ab054 100644
--- a/actionview/lib/action_view/helpers/rendering_helper.rb
+++ b/actionview/lib/action_view/helpers/rendering_helper.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module ActionView
- module Helpers
+ module Helpers #:nodoc:
# = Action View Rendering
#
# Implements methods that allow rendering from a view context.
diff --git a/actionview/lib/action_view/helpers/sanitize_helper.rb b/actionview/lib/action_view/helpers/sanitize_helper.rb
index 713b2fbb45..275a2dffb4 100644
--- a/actionview/lib/action_view/helpers/sanitize_helper.rb
+++ b/actionview/lib/action_view/helpers/sanitize_helper.rb
@@ -5,7 +5,7 @@ require "rails-html-sanitizer"
module ActionView
# = Action View Sanitize Helpers
- module Helpers
+ module Helpers #:nodoc:
# The SanitizeHelper module provides a set of methods for scrubbing text of undesired HTML elements.
# These helper methods extend Action View making them callable within your template files.
module SanitizeHelper
diff --git a/actionview/lib/action_view/helpers/tags.rb b/actionview/lib/action_view/helpers/tags.rb
index 2552ebba4e..566668b958 100644
--- a/actionview/lib/action_view/helpers/tags.rb
+++ b/actionview/lib/action_view/helpers/tags.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module ActionView
- module Helpers
+ module Helpers #:nodoc:
module Tags #:nodoc:
extend ActiveSupport::Autoload
diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb
index 75c1161de1..e663892592 100644
--- a/actionview/lib/action_view/helpers/translation_helper.rb
+++ b/actionview/lib/action_view/helpers/translation_helper.rb
@@ -6,7 +6,7 @@ require "i18n/exceptions"
module ActionView
# = Action View Translation Helpers
- module Helpers
+ module Helpers #:nodoc:
module TranslationHelper
extend ActiveSupport::Concern
diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb
index f2edcb750c..beb0a18b65 100644
--- a/actionview/lib/action_view/renderer/partial_renderer.rb
+++ b/actionview/lib/action_view/renderer/partial_renderer.rb
@@ -52,12 +52,12 @@ module ActionView
# <%= render partial: "ad", locals: { ad: ad } %>
# <% end %>
#
- # This would first render "advertiser/_account.html.erb" with @buyer passed in as the local variable +account+, then
- # render "advertiser/_ad.html.erb" and pass the local variable +ad+ to the template for display.
+ # This would first render <tt>advertiser/_account.html.erb</tt> with <tt>@buyer</tt> passed in as the local variable +account+, then
+ # render <tt>advertiser/_ad.html.erb</tt> and pass the local variable +ad+ to the template for display.
#
# == The :as and :object options
#
- # By default <tt>ActionView::PartialRenderer</tt> doesn't have any local variables.
+ # By default ActionView::PartialRenderer doesn't have any local variables.
# The <tt>:object</tt> option can be used to pass an object to the partial. For instance:
#
# <%= render partial: "account", object: @buyer %>
@@ -85,7 +85,7 @@ module ActionView
#
# <%= render partial: "ad", collection: @advertisements %>
#
- # This will render "advertiser/_ad.html.erb" and pass the local variable +ad+ to the template for display. An
+ # This will render <tt>advertiser/_ad.html.erb</tt> and pass the local variable +ad+ to the template for display. An
# iteration object will automatically be made available to the template with a name of the form
# +partial_name_iteration+. The iteration object has knowledge about which index the current object has in
# the collection and the total size of the collection. The iteration object also has two convenience methods,
@@ -100,7 +100,7 @@ module ActionView
#
# <%= render partial: "ad", collection: @advertisements, spacer_template: "ad_divider" %>
#
- # If the given <tt>:collection</tt> is +nil+ or empty, <tt>render</tt> will return nil. This will allow you
+ # If the given <tt>:collection</tt> is +nil+ or empty, <tt>render</tt> will return +nil+. This will allow you
# to specify a text which will be displayed instead by using this form:
#
# <%= render(partial: "ad", collection: @advertisements) || "There's no ad to be displayed" %>
@@ -114,18 +114,18 @@ module ActionView
#
# <%= render partial: "advertisement/ad", locals: { ad: @advertisement } %>
#
- # This will render the partial "advertisement/_ad.html.erb" regardless of which controller this is being called from.
+ # This will render the partial <tt>advertisement/_ad.html.erb</tt> regardless of which controller this is being called from.
#
- # == \Rendering objects that respond to `to_partial_path`
+ # == \Rendering objects that respond to +to_partial_path+
#
# Instead of explicitly naming the location of a partial, you can also let PartialRenderer do the work
- # and pick the proper path by checking `to_partial_path` method.
+ # and pick the proper path by checking +to_partial_path+ method.
#
# # @account.to_partial_path returns 'accounts/account', so it can be used to replace:
# # <%= render partial: "accounts/account", locals: { account: @account} %>
# <%= render partial: @account %>
#
- # # @posts is an array of Post instances, so every post record returns 'posts/post' on `to_partial_path`,
+ # # @posts is an array of Post instances, so every post record returns 'posts/post' on +to_partial_path+,
# # that's why we can replace:
# # <%= render partial: "posts/post", collection: @posts %>
# <%= render partial: @posts %>
@@ -145,7 +145,7 @@ module ActionView
# # <%= render partial: "accounts/account", locals: { account: @account} %>
# <%= render @account %>
#
- # # @posts is an array of Post instances, so every post record returns 'posts/post' on `to_partial_path`,
+ # # @posts is an array of Post instances, so every post record returns 'posts/post' on +to_partial_path+,
# # that's why we can replace:
# # <%= render partial: "posts/post", collection: @posts %>
# <%= render @posts %>
diff --git a/actionview/lib/action_view/template/handlers.rb b/actionview/lib/action_view/template/handlers.rb
index b3df0aa606..7ec76dcc3f 100644
--- a/actionview/lib/action_view/template/handlers.rb
+++ b/actionview/lib/action_view/template/handlers.rb
@@ -2,7 +2,7 @@
module ActionView #:nodoc:
# = Action View Template Handlers
- class Template
+ class Template #:nodoc:
module Handlers #:nodoc:
autoload :Raw, "action_view/template/handlers/raw"
autoload :ERB, "action_view/template/handlers/erb"
diff --git a/actionview/lib/action_view/template/html.rb b/actionview/lib/action_view/template/html.rb
index 540597efa1..a262c6d9ad 100644
--- a/actionview/lib/action_view/template/html.rb
+++ b/actionview/lib/action_view/template/html.rb
@@ -2,7 +2,7 @@
module ActionView #:nodoc:
# = Action View HTML Template
- class Template
+ class Template #:nodoc:
class HTML #:nodoc:
attr_accessor :type
diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb
index 708dee3164..a58d375293 100644
--- a/actionview/lib/action_view/template/resolver.rb
+++ b/actionview/lib/action_view/template/resolver.rb
@@ -310,13 +310,13 @@ module ActionView
# ==== Examples
#
# Default pattern, loads views the same way as previous versions of rails, eg. when you're
- # looking for `users/new` it will produce query glob: `users/new{.{en},}{.{html,js},}{.{erb,haml},}`
+ # looking for <tt>users/new</tt> it will produce query glob: <tt>users/new{.{en},}{.{html,js},}{.{erb,haml},}</tt>
#
# FileSystemResolver.new("/path/to/views", ":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}")
#
# This one allows you to keep files with different formats in separate subdirectories,
- # eg. `users/new.html` will be loaded from `users/html/new.erb` or `users/new.html.erb`,
- # `users/new.js` from `users/js/new.erb` or `users/new.js.erb`, etc.
+ # eg. <tt>users/new.html</tt> will be loaded from <tt>users/html/new.erb</tt> or <tt>users/new.html.erb</tt>,
+ # <tt>users/new.js</tt> from <tt>users/js/new.erb</tt> or <tt>users/new.js.erb</tt>, etc.
#
# FileSystemResolver.new("/path/to/views", ":prefix/{:formats/,}:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}")
#
diff --git a/actionview/lib/action_view/template/text.rb b/actionview/lib/action_view/template/text.rb
index f070005881..f8d6c2811f 100644
--- a/actionview/lib/action_view/template/text.rb
+++ b/actionview/lib/action_view/template/text.rb
@@ -2,7 +2,7 @@
module ActionView #:nodoc:
# = Action View Text Template
- class Template
+ class Template #:nodoc:
class Text #:nodoc:
attr_accessor :type
diff --git a/actionview/lib/action_view/template/types.rb b/actionview/lib/action_view/template/types.rb
index f0f37c9722..67b7a62de6 100644
--- a/actionview/lib/action_view/template/types.rb
+++ b/actionview/lib/action_view/template/types.rb
@@ -3,7 +3,7 @@
require "active_support/core_ext/module/attribute_accessors"
module ActionView
- class Template
+ class Template #:nodoc:
class Types
class Type
SET = Struct.new(:symbols).new([ :html, :text, :js, :css, :xml, :json ])
diff --git a/activemodel/lib/active_model/callbacks.rb b/activemodel/lib/active_model/callbacks.rb
index 5768eec7f5..8fa9680cb1 100644
--- a/activemodel/lib/active_model/callbacks.rb
+++ b/activemodel/lib/active_model/callbacks.rb
@@ -103,8 +103,8 @@ module ActiveModel
# end
# end
#
- # NOTE: +method_name+ passed to `define_model_callbacks` must not end with
- # `!`, `?` or `=`.
+ # NOTE: +method_name+ passed to define_model_callbacks must not end with
+ # <tt>!</tt>, <tt>?</tt> or <tt>=</tt>.
def define_model_callbacks(*callbacks)
options = callbacks.extract_options!
options = {
diff --git a/activerecord/lib/active_record/attribute_methods/dirty.rb b/activerecord/lib/active_record/attribute_methods/dirty.rb
index c622df132e..4f957ac3ca 100644
--- a/activerecord/lib/active_record/attribute_methods/dirty.rb
+++ b/activerecord/lib/active_record/attribute_methods/dirty.rb
@@ -94,7 +94,7 @@ module ActiveRecord
end
# Did this attribute change when we last saved? This method can be invoked
- # as `saved_change_to_name?` instead of `saved_change_to_attribute?("name")`.
+ # as +saved_change_to_name?+ instead of <tt>saved_change_to_attribute?("name")</tt>.
# Behaves similarly to +attribute_changed?+. This method is useful in
# after callbacks to determine if the call to save changed a certain
# attribute.
@@ -117,8 +117,8 @@ module ActiveRecord
# Behaves similarly to +attribute_change+. This method is useful in after
# callbacks, to see the change in an attribute that just occurred
#
- # This method can be invoked as `saved_change_to_name` in instead of
- # `saved_change_to_attribute("name")`
+ # This method can be invoked as +saved_change_to_name+ in instead of
+ # <tt>saved_change_to_attribute("name")</tt>
def saved_change_to_attribute(attr_name)
mutations_before_last_save.change_to_attribute(attr_name)
end
@@ -131,7 +131,7 @@ module ActiveRecord
mutations_before_last_save.original_value(attr_name)
end
- # Did the last call to `save` have any changes to change?
+ # Did the last call to +save+ have any changes to change?
def saved_changes?
mutations_before_last_save.any_changes?
end
@@ -141,37 +141,37 @@ module ActiveRecord
mutations_before_last_save.changes
end
- # Alias for `attribute_changed?`
+ # Alias for +attribute_changed?+
def will_save_change_to_attribute?(attr_name, **options)
mutations_from_database.changed?(attr_name, **options)
end
- # Alias for `attribute_change`
+ # Alias for +attribute_change+
def attribute_change_to_be_saved(attr_name)
mutations_from_database.change_to_attribute(attr_name)
end
- # Alias for `attribute_was`
+ # Alias for +attribute_was+
def attribute_in_database(attr_name)
mutations_from_database.original_value(attr_name)
end
- # Alias for `changed?`
+ # Alias for +changed?+
def has_changes_to_save?
mutations_from_database.any_changes?
end
- # Alias for `changes`
+ # Alias for +changes+
def changes_to_save
mutations_from_database.changes
end
- # Alias for `changed`
+ # Alias for +changed+
def changed_attribute_names_to_save
changes_to_save.keys
end
- # Alias for `changed_attributes`
+ # Alias for +changed_attributes+
def attributes_in_database
changes_to_save.transform_values(&:first)
end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index f36c1f111a..f57c7a5d4d 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -406,6 +406,8 @@ module ActiveRecord
#
# Defaults to false.
#
+ # Only supported on the MySQL adapter, ignored elsewhere.
+ #
# ====== Add a column
#
# change_table(:suppliers) do |t|
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
index 3683522a0c..7cd086084a 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -33,7 +33,7 @@ module ActiveRecord
string: { name: "varchar", limit: 255 },
text: { name: "text", limit: 65535 },
integer: { name: "int", limit: 4 },
- float: { name: "float" },
+ float: { name: "float", limit: 24 },
decimal: { name: "decimal" },
datetime: { name: "datetime" },
timestamp: { name: "timestamp" },
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
index d6f357bcc3..6fdd666486 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
@@ -76,7 +76,7 @@ module ActiveRecord
##
# :singleton-method:
# Indicates whether boolean values are stored in sqlite3 databases as 1
- # and 0 or 't' and 'f'. Leaving `ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer`
+ # and 0 or 't' and 'f'. Leaving <tt>ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer</tt>
# set to false is deprecated. SQLite databases have used 't' and 'f' to
# serialize boolean values and must have old data converted to 1 and 0
# (its native boolean serialization) before setting this flag to true.
@@ -85,7 +85,7 @@ module ActiveRecord
# ExampleModel.where("boolean_column = 't'").update_all(boolean_column: 1)
# ExampleModel.where("boolean_column = 'f'").update_all(boolean_column: 0)
# for all models and all boolean columns, after which the flag must be set
- # to true by adding the following to your application.rb file:
+ # to true by adding the following to your <tt>application.rb</tt> file:
#
# Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
class_attribute :represent_boolean_as_integer, default: false
diff --git a/activerecord/lib/active_record/define_callbacks.rb b/activerecord/lib/active_record/define_callbacks.rb
index 2c8783dcc9..87ecd7cec5 100644
--- a/activerecord/lib/active_record/define_callbacks.rb
+++ b/activerecord/lib/active_record/define_callbacks.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
module ActiveRecord
- # This module exists because `ActiveRecord::AttributeMethods::Dirty` needs to
- # define callbacks, but continue to have its version of `save` be the super
- # method of `ActiveRecord::Callbacks`. This will be removed when the removal
+ # This module exists because ActiveRecord::AttributeMethods::Dirty needs to
+ # define callbacks, but continue to have its version of +save+ be the super
+ # method of ActiveRecord::Callbacks. This will be removed when the removal
# of deprecated code removes this need.
module DefineCallbacks
extend ActiveSupport::Concern
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 4940e122f4..12169fffa9 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -147,7 +147,7 @@ module ActiveRecord
# unwanted inter-test dependencies. Methods used by multiple fixtures should be defined in a module
# that is included in ActiveRecord::FixtureSet.context_class.
#
- # - define a helper method in `test_helper.rb`
+ # - define a helper method in <tt>test_helper.rb</tt>
# module FixtureFileHelpers
# def file_sha(path)
# Digest::SHA2.hexdigest(File.read(Rails.root.join('test/fixtures', path)))
diff --git a/activerecord/lib/active_record/no_touching.rb b/activerecord/lib/active_record/no_touching.rb
index c573deb63a..754c891884 100644
--- a/activerecord/lib/active_record/no_touching.rb
+++ b/activerecord/lib/active_record/no_touching.rb
@@ -6,7 +6,7 @@ module ActiveRecord
extend ActiveSupport::Concern
module ClassMethods
- # Lets you selectively disable calls to `touch` for the
+ # Lets you selectively disable calls to +touch+ for the
# duration of a block.
#
# ==== Examples
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 1297e0cde7..fbbf9082cc 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -353,7 +353,7 @@ module ActiveRecord
# Wrapper around #increment that writes the update to the database.
# Only +attribute+ is updated; the record itself is not saved.
# This means that any other modified attributes will still be dirty.
- # Validations and callbacks are skipped. Supports the `touch` option from
+ # Validations and callbacks are skipped. Supports the +touch+ option from
# +update_counters+, see that for more.
# Returns +self+.
def increment!(attribute, by = 1, touch: nil)
@@ -374,7 +374,7 @@ module ActiveRecord
# Wrapper around #decrement that writes the update to the database.
# Only +attribute+ is updated; the record itself is not saved.
# This means that any other modified attributes will still be dirty.
- # Validations and callbacks are skipped. Supports the `touch` option from
+ # Validations and callbacks are skipped. Supports the +touch+ option from
# +update_counters+, see that for more.
# Returns +self+.
def decrement!(attribute, by = 1, touch: nil)
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index e35049bb41..00ff20f4d7 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -1036,20 +1036,12 @@ module ActiveRecord
def scopes
scopes = @previous_reflection.scopes
- if @previous_reflection.options[:source_type]
- scopes + [@previous_reflection.source_type_scope]
- else
- scopes
- end
+ scopes << @previous_reflection.source_type_scope
end
def join_scopes(table, predicate_builder) # :nodoc:
scopes = @previous_reflection.join_scopes(table, predicate_builder) + super
- if @previous_reflection.options[:source_type]
- scopes + [@previous_reflection.source_type_scope]
- else
- scopes
- end
+ scopes << @previous_reflection.source_type_scope
end
def klass
@@ -1100,10 +1092,6 @@ module ActiveRecord
@reflection.constraints
end
- def alias_candidate(name)
- "#{plural_name}_#{name}_join"
- end
-
def alias_name
Arel::Table.new(table_name, type_caster: klass.type_caster)
end
diff --git a/activerecord/lib/active_record/relation/delegation.rb b/activerecord/lib/active_record/relation/delegation.rb
index 4793f2a49b..1aa85993ca 100644
--- a/activerecord/lib/active_record/relation/delegation.rb
+++ b/activerecord/lib/active_record/relation/delegation.rb
@@ -75,13 +75,6 @@ module ActiveRecord
end
end
end
-
- def delegate(method, opts = {})
- @delegation_mutex.synchronize do
- return if method_defined?(method)
- super
- end
- end
end
private
@@ -93,7 +86,6 @@ module ActiveRecord
elsif arel.respond_to?(method)
ActiveSupport::Deprecation.warn \
"Delegating #{method} to arel is deprecated and will be removed in Rails 6.0."
- self.class.delegate method, to: :arel
arel.public_send(method, *args, &block)
else
super
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index d2e1892ae7..8d0311fabd 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -132,14 +132,13 @@ HEADER
else
tbl.print ", id: false"
end
- tbl.print ", force: :cascade"
table_options = @connection.table_options(table)
if table_options.present?
tbl.print ", #{format_options(table_options)}"
end
- tbl.puts " do |t|"
+ tbl.puts ", force: :cascade do |t|"
# then dump all non-primary key columns
columns.each do |column|
diff --git a/activerecord/test/cases/adapters/mysql2/table_options_test.rb b/activerecord/test/cases/adapters/mysql2/table_options_test.rb
index 6183d66b63..9f6bd38a8c 100644
--- a/activerecord/test/cases/adapters/mysql2/table_options_test.rb
+++ b/activerecord/test/cases/adapters/mysql2/table_options_test.rb
@@ -17,28 +17,28 @@ class Mysql2TableOptionsTest < ActiveRecord::Mysql2TestCase
test "table options with ENGINE" do
@connection.create_table "mysql_table_options", force: true, options: "ENGINE=MyISAM"
output = dump_table_schema("mysql_table_options")
- options = %r{create_table "mysql_table_options", force: :cascade, options: "(?<options>.*)"}.match(output)[:options]
+ options = %r{create_table "mysql_table_options", options: "(?<options>.*)"}.match(output)[:options]
assert_match %r{ENGINE=MyISAM}, options
end
test "table options with ROW_FORMAT" do
@connection.create_table "mysql_table_options", force: true, options: "ROW_FORMAT=REDUNDANT"
output = dump_table_schema("mysql_table_options")
- options = %r{create_table "mysql_table_options", force: :cascade, options: "(?<options>.*)"}.match(output)[:options]
+ options = %r{create_table "mysql_table_options", options: "(?<options>.*)"}.match(output)[:options]
assert_match %r{ROW_FORMAT=REDUNDANT}, options
end
test "table options with CHARSET" do
@connection.create_table "mysql_table_options", force: true, options: "CHARSET=utf8mb4"
output = dump_table_schema("mysql_table_options")
- options = %r{create_table "mysql_table_options", force: :cascade, options: "(?<options>.*)"}.match(output)[:options]
+ options = %r{create_table "mysql_table_options", options: "(?<options>.*)"}.match(output)[:options]
assert_match %r{CHARSET=utf8mb4}, options
end
test "table options with COLLATE" do
@connection.create_table "mysql_table_options", force: true, options: "COLLATE=utf8mb4_bin"
output = dump_table_schema("mysql_table_options")
- options = %r{create_table "mysql_table_options", force: :cascade, options: "(?<options>.*)"}.match(output)[:options]
+ options = %r{create_table "mysql_table_options", options: "(?<options>.*)"}.match(output)[:options]
assert_match %r{COLLATE=utf8mb4_bin}, options
end
end
diff --git a/activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb b/activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb
index d0a09f6481..b01f5d7f5a 100644
--- a/activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb
+++ b/activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb
@@ -62,7 +62,7 @@ class Mysql2UnsignedTypeTest < ActiveRecord::Mysql2TestCase
schema = dump_table_schema "unsigned_types"
assert_match %r{t\.integer\s+"unsigned_integer",\s+unsigned: true$}, schema
assert_match %r{t\.bigint\s+"unsigned_bigint",\s+unsigned: true$}, schema
- assert_match %r{t\.float\s+"unsigned_float",\s+limit: 24,\s+unsigned: true$}, schema
+ assert_match %r{t\.float\s+"unsigned_float",\s+unsigned: true$}, schema
assert_match %r{t\.decimal\s+"unsigned_decimal",\s+precision: 10,\s+scale: 2,\s+unsigned: true$}, schema
end
end
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index da5e830ebc..4d8368fd8a 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -5,6 +5,7 @@ require "models/bird"
require "models/post"
require "models/comment"
require "models/company"
+require "models/contract"
require "models/customer"
require "models/developer"
require "models/computer"
@@ -12,9 +13,7 @@ require "models/invoice"
require "models/line_item"
require "models/order"
require "models/parrot"
-require "models/person"
require "models/pirate"
-require "models/reader"
require "models/ship"
require "models/ship_part"
require "models/tag"
@@ -496,7 +495,7 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociationWithAcceptsNestedAttrib
end
class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCase
- fixtures :companies, :people
+ fixtures :companies, :developers
def test_invalid_adding
firm = Firm.find(1)
@@ -591,12 +590,12 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCa
end
def test_assign_ids_for_through_a_belongs_to
- post = Post.new(title: "Assigning IDs works!", body: "You heard it here first, folks!")
- post.person_ids = [people(:david).id, people(:michael).id]
- post.save
- post.reload
- assert_equal 2, post.people.length
- assert_includes post.people, people(:david)
+ firm = Firm.new("name" => "Apple")
+ firm.developer_ids = [developers(:david).id, developers(:jamis).id]
+ firm.save
+ firm.reload
+ assert_equal 2, firm.developers.length
+ assert_includes firm.developers, developers(:david)
end
def test_build_before_save
diff --git a/activerecord/test/cases/comment_test.rb b/activerecord/test/cases/comment_test.rb
index f2ec5d6518..1bcafd4b55 100644
--- a/activerecord/test/cases/comment_test.rb
+++ b/activerecord/test/cases/comment_test.rb
@@ -111,7 +111,7 @@ if ActiveRecord::Base.connection.supports_comments?
# And check that these changes are reflected in dump
output = dump_table_schema "commenteds"
- assert_match %r[create_table "commenteds",.+\s+comment: "A table with comment"], output
+ assert_match %r[create_table "commenteds",.*\s+comment: "A table with comment"], output
assert_match %r[t\.string\s+"name",\s+comment: "Comment should help clarify the column purpose"], output
assert_match %r[t\.string\s+"obvious"\n], output
assert_match %r[t\.string\s+"content",\s+comment: "Whoa, content describes itself!"], output
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb
index df83fe0ea1..e0888f5fe9 100644
--- a/activerecord/test/cases/primary_keys_test.rb
+++ b/activerecord/test/cases/primary_keys_test.rb
@@ -434,7 +434,7 @@ if current_adapter?(:PostgreSQLAdapter, :Mysql2Adapter)
test "schema dump primary key with serial/integer" do
@connection.create_table(:widgets, id: @pk_type, force: true)
schema = dump_table_schema "widgets"
- assert_match %r{create_table "widgets", id: :#{@pk_type}, force: :cascade}, schema
+ assert_match %r{create_table "widgets", id: :#{@pk_type}, }, schema
end
if current_adapter?(:Mysql2Adapter)
@@ -447,7 +447,7 @@ if current_adapter?(:PostgreSQLAdapter, :Mysql2Adapter)
assert column.unsigned?
schema = dump_table_schema "widgets"
- assert_match %r{create_table "widgets", id: :integer, unsigned: true, force: :cascade}, schema
+ assert_match %r{create_table "widgets", id: :integer, unsigned: true, }, schema
end
test "bigint primary key with unsigned" do
@@ -459,7 +459,7 @@ if current_adapter?(:PostgreSQLAdapter, :Mysql2Adapter)
assert column.unsigned?
schema = dump_table_schema "widgets"
- assert_match %r{create_table "widgets", id: :bigint, unsigned: true, force: :cascade}, schema
+ assert_match %r{create_table "widgets", id: :bigint, unsigned: true, }, schema
end
end
end
diff --git a/activerecord/test/cases/relation/delegation_test.rb b/activerecord/test/cases/relation/delegation_test.rb
index 8ffb9f163b..04d688ac53 100644
--- a/activerecord/test/cases/relation/delegation_test.rb
+++ b/activerecord/test/cases/relation/delegation_test.rb
@@ -32,6 +32,7 @@ module ActiveRecord
def test_deprecate_arel_delegation
AREL_METHODS.each do |method|
assert_deprecated { target.public_send(method) }
+ assert_deprecated { target.public_send(method) }
end
end
end
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb
index eb9b257da9..799a65c61e 100644
--- a/activerecord/test/cases/schema_dumper_test.rb
+++ b/activerecord/test/cases/schema_dumper_test.rb
@@ -66,7 +66,7 @@ class SchemaDumperTest < ActiveRecord::TestCase
def test_schema_dump_uses_force_cascade_on_create_table
output = dump_table_schema "authors"
- assert_match %r{create_table "authors", force: :cascade}, output
+ assert_match %r{create_table "authors",.* force: :cascade}, output
end
def test_schema_dump_excludes_sqlite_sequence
@@ -207,20 +207,25 @@ class SchemaDumperTest < ActiveRecord::TestCase
end
def test_schema_dump_should_use_false_as_default
- output = standard_dump
+ output = dump_table_schema "booleans"
assert_match %r{t\.boolean\s+"has_fun",.+default: false}, output
end
def test_schema_dump_does_not_include_limit_for_text_field
- output = standard_dump
+ output = dump_table_schema "admin_users"
assert_match %r{t\.text\s+"params"$}, output
end
def test_schema_dump_does_not_include_limit_for_binary_field
- output = standard_dump
+ output = dump_table_schema "binaries"
assert_match %r{t\.binary\s+"data"$}, output
end
+ def test_schema_dump_does_not_include_limit_for_float_field
+ output = dump_table_schema "numeric_data"
+ assert_match %r{t\.float\s+"temperature"$}, output
+ end
+
if current_adapter?(:Mysql2Adapter)
def test_schema_dump_includes_length_for_mysql_binary_fields
output = standard_dump
diff --git a/activestorage/app/jobs/active_storage/purge_job.rb b/activestorage/app/jobs/active_storage/purge_job.rb
index 369c07929d..990ab27c9f 100644
--- a/activestorage/app/jobs/active_storage/purge_job.rb
+++ b/activestorage/app/jobs/active_storage/purge_job.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-# Provides delayed purging of attachments or blobs using their +purge_later+ method.
+# Provides delayed purging of ActiveStorage::Blob records via ActiveStorage::Blob#purge_later.
class ActiveStorage::PurgeJob < ActiveJob::Base
# FIXME: Limit this to a custom ActiveStorage error
retry_on StandardError
- def perform(attachment_or_blob)
- attachment_or_blob.purge
+ def perform(blob)
+ blob.purge
end
end
diff --git a/activestorage/app/models/active_storage/attachment.rb b/activestorage/app/models/active_storage/attachment.rb
index ad43845e4e..2a1c20b7db 100644
--- a/activestorage/app/models/active_storage/attachment.rb
+++ b/activestorage/app/models/active_storage/attachment.rb
@@ -14,17 +14,15 @@ class ActiveStorage::Attachment < ActiveRecord::Base
delegate_missing_to :blob
- # Purging an attachment will purge the blob (delete the file on the service, then destroy the record)
- # and then destroy the attachment itself.
+ # Synchronously purges the blob (deletes it from the configured service) and destroys the attachment.
def purge
blob.purge
destroy
end
- # Purging an attachment means purging the blob, which means talking to the service, which means
- # talking over the Internet. Whenever you're doing that, it's a good idea to put that work in a job,
- # so it doesn't hold up other operations. That's what +purge_later+ provides.
+ # Destroys the attachment and asynchronously purges the blob (deletes it from the configured service).
def purge_later
- ActiveStorage::PurgeJob.perform_later(self)
+ blob.purge_later
+ destroy
end
end
diff --git a/activestorage/lib/active_storage/service/disk_service.rb b/activestorage/lib/active_storage/service/disk_service.rb
index 5aa8d74a5a..f600753a08 100644
--- a/activestorage/lib/active_storage/service/disk_service.rb
+++ b/activestorage/lib/active_storage/service/disk_service.rb
@@ -66,7 +66,7 @@ module ActiveStorage
verified_key_with_expiration,
filename: filename, disposition: disposition, content_type: content_type
else
- "/rails/active_storage/disk/#{verified_key_with_expiration}/#{filename}?disposition=#{disposition}&content_type=#{content_type}"
+ "/rails/active_storage/disk/#{verified_key_with_expiration}/#{filename}?content_type=#{content_type}&disposition=#{disposition}"
end
payload[:url] = generated_url
diff --git a/activestorage/test/service/disk_service_test.rb b/activestorage/test/service/disk_service_test.rb
index f57e44536a..e07d1d88bc 100644
--- a/activestorage/test/service/disk_service_test.rb
+++ b/activestorage/test/service/disk_service_test.rb
@@ -8,7 +8,7 @@ class ActiveStorage::Service::DiskServiceTest < ActiveSupport::TestCase
include ActiveStorage::Service::SharedServiceTests
test "url generation" do
- assert_match(/rails\/active_storage\/disk\/.*\/avatar\.png\?.+disposition=inline/,
+ assert_match(/rails\/active_storage\/disk\/.*\/avatar\.png\?content_type=image%2Fpng&disposition=inline/,
@service.url(FIXTURE_KEY, expires_in: 5.minutes, disposition: "inline; filename=\"avatar.png\"", filename: "avatar.png", content_type: "image/png"))
end
end
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 3ffe21e559..ad2f21205f 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -85,7 +85,7 @@ module ActiveSupport #:nodoc:
# handles the new constants.
#
# If child.rb is being autoloaded, its constants will be added to
- # autoloaded_constants. If it was being `require`d, they will be discarded.
+ # autoloaded_constants. If it was being required, they will be discarded.
#
# This is handled by walking back up the watch stack and adding the constants
# found by child.rb to the list of original constants in parent.rb.
diff --git a/guides/source/5_0_release_notes.md b/guides/source/5_0_release_notes.md
index 6d53e1c2b4..3805fd2a63 100644
--- a/guides/source/5_0_release_notes.md
+++ b/guides/source/5_0_release_notes.md
@@ -55,7 +55,7 @@ information.
### API Applications
Rails can now be used to create slimmed down API only applications.
-This is useful for creating and serving APIs similar to [Twitter](https://dev.twitter.com) or [GitHub](https://developer.github.com) API,
+This is useful for creating and serving APIs similar to [Twitter](https://dev.twitter.com) or [GitHub](https://developer.github.com) API,
that can be used to serve public facing, as well as, for custom applications.
You can generate a new api Rails app using:
@@ -77,7 +77,7 @@ This will do three main things:
you generate a new resource.
The application provides a base for APIs,
-that can then be [configured to pull in functionality](api_app.html) as suitable for the application's needs.
+that can then be [configured to pull in functionality](api_app.html) as suitable for the application's needs.
See the [Using Rails for API-only Applications](api_app.html) guide for more
information.
diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md
index ba26c922be..96ef9c4450 100644
--- a/guides/source/action_mailer_basics.md
+++ b/guides/source/action_mailer_basics.md
@@ -413,7 +413,7 @@ inside of Action Controller, so you can use all the same options, such as
#### Caching mailer view
-You can do cache in mailer views like in application views using `cache` method.
+You can perform fragment caching in mailer views like in application views using the `cache` method.
```
<% cache do %>
@@ -427,6 +427,9 @@ And in order to use this feature, you need to configure your application with th
config.action_mailer.perform_caching = true
```
+Fragment caching is also supported in multipart emails.
+Read more about caching in the [Rails caching guide](caching_with_rails.html).
+
### Action Mailer Layouts
Just like controller views, you can also have mailer layouts. The layout name
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 53cacfa6ea..678b80516f 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -1393,7 +1393,7 @@ end
```
NOTE: The `default_scope` is also applied while creating/building a record
-when the scope arguments are given as a `Hash`. It is not applied while
+when the scope arguments are given as a `Hash`. It is not applied while
updating a record. E.g.:
```ruby
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index 20d09e65b3..9f89e666dc 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -135,9 +135,9 @@ NOTE: Defined in `active_support/core_ext/object/blank.rb`.
### `duplicable?`
-In Ruby 2.4 most objects can be duplicated via `dup` or `clone` except
+In Ruby 2.4 most objects can be duplicated via `dup` or `clone` except
methods and certain numbers. Though Ruby 2.2 and 2.3 can't duplicate `nil`,
-`false`, `true`, and symbols as well as instances `Float`, `Fixnum`,
+`false`, `true`, and symbols as well as instances `Float`, `Fixnum`,
and `Bignum` instances.
```ruby
diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md
index 6cdce5c2f4..2e5f4e3878 100644
--- a/guides/source/caching_with_rails.md
+++ b/guides/source/caching_with_rails.md
@@ -387,9 +387,9 @@ store is not appropriate for large application deployments. However, it can
work well for small, low traffic sites with only a couple of server processes,
as well as development and test environments.
-New Rails projects are configured to use this implementation in development environment by default.
+New Rails projects are configured to use this implementation in development environment by default.
-NOTE: Since processes will not share cache data when using `:memory_store`,
+NOTE: Since processes will not share cache data when using `:memory_store`,
it will not be possible to manually read, write or expire the cache via the Rails console.
### ActiveSupport::Cache::FileStore
@@ -580,7 +580,7 @@ Caching in Development
----------------------
It's common to want to test the caching strategy of your application
-in development mode. Rails provides the rake task `dev:cache` to
+in development mode. Rails provides the rake task `dev:cache` to
easily toggle caching on/off.
```bash
diff --git a/guides/source/kindle/toc.html.erb b/guides/source/kindle/toc.html.erb
index f310edd3a1..0f4228ed6b 100644
--- a/guides/source/kindle/toc.html.erb
+++ b/guides/source/kindle/toc.html.erb
@@ -14,7 +14,7 @@ Ruby on Rails Guides
<% if document['work_in_progress']%>(WIP)<% end %>
</li>
<% end %>
- </ul>
+ </ul>
<% end %>
<hr />
<ul>
diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md
index 6bce73ccad..27cef2bd27 100644
--- a/guides/source/working_with_javascript_in_rails.md
+++ b/guides/source/working_with_javascript_in_rails.md
@@ -24,11 +24,11 @@ In order to understand Ajax, you must first understand what a web browser does
normally.
When you type `http://localhost:3000` into your browser's address bar and hit
-'Go,' the browser (your 'client') makes a request to the server. It parses the
+'Go', the browser (your 'client') makes a request to the server. It parses the
response, then fetches all associated assets, like JavaScript files,
stylesheets and images. It then assembles the page. If you click a link, it
does the same process: fetch the page, fetch the assets, put it all together,
-show you the results. This is called the 'request response cycle.'
+show you the results. This is called the 'request response cycle'.
JavaScript can also make requests to the server, and parse the response. It
also has the ability to update information on the page. Combining these two
@@ -57,7 +57,7 @@ will show you how Rails can help you write websites in this way, but it's
all built on top of this fairly simple technique.
Unobtrusive JavaScript
--------------------------------------
+----------------------
Rails uses a technique called "Unobtrusive JavaScript" to handle attaching
JavaScript to the DOM. This is generally considered to be a best-practice
@@ -139,7 +139,7 @@ JavaScript) in this style, and you can expect that many libraries will also
follow this pattern.
Built-in Helpers
-----------------------
+----------------
### Remote elements
@@ -372,9 +372,9 @@ is also useful for manipulating form data before serialization. The
`ajax:beforeSend` event is also useful for adding custom request headers.
If you stop the `ajax:aborted:file` event, the default behavior of allowing the
-browser to submit the form via normal means (i.e. non-AJAX submission) will be
+browser to submit the form via normal means (i.e. non-Ajax submission) will be
canceled and the form will not be submitted at all. This is useful for
-implementing your own AJAX file upload workaround.
+implementing your own Ajax file upload workaround.
### Rails-ujs event handlers
diff --git a/railties/lib/rails/api/generator.rb b/railties/lib/rails/api/generator.rb
index 6e5eec2e34..3405560b74 100644
--- a/railties/lib/rails/api/generator.rb
+++ b/railties/lib/rails/api/generator.rb
@@ -6,8 +6,11 @@ class RDoc::Generator::API < RDoc::Generator::SDoc # :nodoc:
RDoc::RDoc.add_generator self
def generate_class_tree_level(classes, visited = {})
- # Only process core extensions on the first visit.
+ # Only process core extensions on the first visit and remove
+ # Active Storage duplicated classes that are at the top level
+ # since they aren't nested under a definition of the `ActiveStorage` module.
if visited.empty?
+ classes = classes.reject { |klass| active_storage?(klass) }
core_exts, classes = classes.partition { |klass| core_extension?(klass) }
super.unshift([ "Core extensions", "", "", build_core_ext_subtree(core_exts, visited) ])
@@ -27,4 +30,8 @@ class RDoc::Generator::API < RDoc::Generator::SDoc # :nodoc:
def core_extension?(klass)
klass.name != "ActiveSupport" && klass.in_files.any? { |file| file.absolute_name.include?("core_ext") }
end
+
+ def active_storage?(klass)
+ klass.name != "ActiveStorage" && klass.in_files.all? { |file| file.absolute_name.include?("active_storage") }
+ end
end
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 31e2a45bff..b65289177f 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -151,7 +151,7 @@ module Rails
end
# Loads and returns the entire raw configuration of database from
- # values stored in `config/database.yml`.
+ # values stored in <tt>config/database.yml</tt>.
def database_configuration
path = paths["config/database"].existent.first
yaml = Pathname.new(path) if path
diff --git a/railties/lib/rails/command/actions.rb b/railties/lib/rails/command/actions.rb
index 2f6827b7f4..cbb743346b 100644
--- a/railties/lib/rails/command/actions.rb
+++ b/railties/lib/rails/command/actions.rb
@@ -3,9 +3,9 @@
module Rails
module Command
module Actions
- # Change to the application's path if there is no config.ru file in current directory.
- # This allows us to run `rails server` from other directories, but still get
- # the main config.ru and properly set the tmp directory.
+ # Change to the application's path if there is no <tt>config.ru</tt> file in current directory.
+ # This allows us to run <tt>rails server</tt> from other directories, but still get
+ # the main <tt>config.ru</tt> and properly set the <tt>tmp</tt> directory.
def set_application_directory!
Dir.chdir(File.expand_path("../..", APP_PATH)) unless File.exist?(File.expand_path("config.ru"))
end
diff --git a/railties/lib/rails/command/base.rb b/railties/lib/rails/command/base.rb
index e92b2042bd..8df4f98d3e 100644
--- a/railties/lib/rails/command/base.rb
+++ b/railties/lib/rails/command/base.rb
@@ -112,8 +112,8 @@ module Rails
# Default file root to place extra files a command might need, placed
# one folder above the command file.
#
- # For a `Rails::Command::TestCommand` placed in `rails/command/test_command.rb`
- # would return `rails/test`.
+ # For a Rails::Command::TestCommand placed in <tt>rails/command/test_command.rb</tt>
+ # would return <tt>rails/test</tt>.
def default_command_root
path = File.expand_path(File.join("../commands", command_root_namespace), __dir__)
path if File.exist?(path)
diff --git a/railties/lib/rails/secrets.rb b/railties/lib/rails/secrets.rb
index 33821dd759..aea72b2d01 100644
--- a/railties/lib/rails/secrets.rb
+++ b/railties/lib/rails/secrets.rb
@@ -44,7 +44,7 @@ module Rails
<<-end_of_template.strip_heredoc
# See `secrets.yml` for tips on generating suitable keys.
# production:
- # external_api_key: 1466aac22e6a869134be3d09b9e89232fc2c2289
+ # external_api_key: 1466aac22e6a869134be3d09b9e89232fc2c2289
end_of_template
end
diff --git a/railties/test/generators/encrypted_secrets_generator_test.rb b/railties/test/generators/encrypted_secrets_generator_test.rb
index 205827e498..eacb5166c0 100644
--- a/railties/test/generators/encrypted_secrets_generator_test.rb
+++ b/railties/test/generators/encrypted_secrets_generator_test.rb
@@ -17,8 +17,8 @@ class EncryptedSecretsGeneratorTest < Rails::Generators::TestCase
assert_file "config/secrets.yml.key", /\w+/
assert File.exist?("config/secrets.yml.enc")
- 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)
+ 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/secrets_test.rb b/railties/test/secrets_test.rb
index 445e216f16..ff6f955a78 100644
--- a/railties/test/secrets_test.rb
+++ b/railties/test/secrets_test.rb
@@ -47,7 +47,7 @@ class Rails::SecretsTest < ActiveSupport::TestCase
ENV["RAILS_MASTER_KEY"] = IO.binread("config/secrets.yml.key").strip
FileUtils.rm("config/secrets.yml.key")
- assert_match "production:\n# external_api_key", Rails::Secrets.read
+ assert_match "# production:\n# external_api_key:", Rails::Secrets.read
ensure
ENV["RAILS_MASTER_KEY"] = old_key
end
@@ -69,7 +69,7 @@ class Rails::SecretsTest < ActiveSupport::TestCase
Rails::Secrets.read_for_editing do |tmp_path|
decrypted_path = tmp_path
- assert_match(/production:\n# external_api_key/, File.read(tmp_path))
+ assert_match(/# production:\n# external_api_key/, File.read(tmp_path))
File.write(tmp_path, "Empty streets, empty nights. The Downtown Lights.")
end