jdufresne
Repos
61
Followers
253
Following
32

Events

delete branch
jdufresne delete branch up-pre-commit
Created at 4 hours ago

Document ActiveRecord::Locking::Pessimistic#with_lock reloads the record

[AR] Fix uniqueness validation on association not using overridden PK

Fix failing ActiveStorage test due to a change upstream in ffmpeg.

The original code which pulls the rotation from tags is still left for older ffmpeg versions whilst the newer ffmpeg version 5.0+ will use the side_data to retrieve the rotation info.

Add Rails.application.message_verifiers

Currently, Rails.application.message_verifier(name) returns a MessageVerifier instance using a secret derived from the given name. Instances created this way always generate messages using the default options for MessageVerifier.new. Also, if there are older options to rotate for message verification, each instance created this way must be configured individually. In cases where Rails itself uses Rails.application.message_verifier (e.g. in Active Storage), discovering the name of the instance may require digging through Rails' source code.

To alleviate these issues, this commit adds a MessageVerifiers factory class, which acts as a central point for configuring and creating MessageVerifier instances. Options passed to MessageVerifiers#rotate will be applied to MessageVerifier instances that MessageVerifiers#[] creates. So the following:

foo_verifier = Rails.application.message_verifier(:foo)
foo_verifier.rotate(old_options)
bar_verifier = Rails.application.message_verifier(:bar)
bar_verifier.rotate(old_options)

Can be rewritten as:

Rails.application.message_verifiers.rotate(old_options)
foo_verifier = Rails.application.message_verifiers[:foo]
bar_verifier = Rails.application.message_verifiers[:bar]

Additionally, Rails.application.message_verifiers supports a :secret_key_base option, so old secret_key_base values can be rotated:

Rails.application.message_verifiers.rotate(secret_key_base: "old secret_key_base")

MessageVerifiers memoizes MessageVerifier instances. This also allows MessageVerifier instances to be overridden entirely:

Rails.application.message_verifiers[:foo] = ActiveSupport::MessageVerifier.new(other_secret)

For parity, this commit also adds a MessageEncryptors factory class, which fulfills the same role for MessageEncryptor instances.

Make app_name consistent between new and update

Previously, the app_name in the App Generator would behave differently when creating a new app and updating an existing app.

When updating an app, app_name is always the Rails::Application class name underscored. When creating a new app, app_name will use whatever the user passes in with a few characters replaced.

This isn't necessarily an issue, but it can lead to extra noise when running app:update. For example, an app generated with rails new MyWebSite will end up with a configuration line like:

config.active_job.queue_name_prefix = "MyWebSite_production"

and running app:update will change it to

config.active_job.queue_name_prefix = "my_web_site_production"

By normalizing app_name when creating an application, the amount of changes when updating is reduced.

Remove duplicate datetime precision default

We already set the default precision for all datetime columns, so there is no need to check it in the timestamps method.

Add table to error for duplicate column definitions

If a migration defines duplicate columns for a table the error message should show which table it concerns.

Merge pull request #46117 from p8/activerecord/improve-duplicate-columns-message

Add table name to error for duplicate column definitions

Improve error-reporting guide

Merge pull request #46112 from sambostock/remove-duplicate-datetime-precision-default

Remove duplicate datetime precision default

Always provide a fallback renderer for Action Text

Follow-up to #45144.

This ensures that a renderer is always available for Action Text, even when ActionController::Base was not previously loaded.

Fixes #46113.

As with #45144, this still avoids loading ActionController::Base unnecessarily when rendering mail after Action Text has been loaded.

Before:

$ bin/rails r 'Benchmark.memory { |x| x.report("load"){ MyBlankMailer.blank_email.body } }'
Calculating -------------------------------------
                load     4.466M memsize (     1.205M retained)
                        29.202k objects (    11.943k retained)
                        50.000  strings (    50.000  retained)

After:

$ bin/rails r 'Benchmark.memory { |x| x.report("load"){ MyBlankMailer.blank_email.body } }'
Calculating -------------------------------------
                load     4.462M memsize (     1.205M retained)
                        29.141k objects (    11.940k retained)
                        50.000  strings (    50.000  retained)

Co-authored-by: Christopher Louvet cl@nonplaces.com

Merge pull request #46119 from jonathanhefner/action_text-renderer-always-fall-back-to-action_controller

Always provide a fallback renderer for Action Text

Merge pull request #46111 from skipkayhil/generate-consistent-app-name

Make app_name consistent between new and update

Keep rescue template paths in an array

Gotta be honest, this is so I can make some hacks. Basically I would like an engine to specify where to find rescue templates, and currently there's no way to add search paths to the debug view lookup context. This commit turns the template path in to an array (that I plan to mutate, but nobody should do that besides me until we make an actual good API).

I added the dup in initialize so in case the array is accidentally mutated we don't leak memory.

Fix #45738

Merge pull request #46125 from mansakondo/fix-pr-45738

Fix #45738

Do not preserve original column collation in change_column for older migrations

Merge pull request #44179 from jonathanhefner/add-message_verifiers-message_encryptors

Add MessageVerifiers and MessageEncryptors classes

Fix Active Support isolated build

Follow-up to #44179.

Example failure: https://buildkite.com/rails/rails/builds/89840#018377c0-87f6-4d46-a0d9-4add41c4a798/1046-2214

Add assert_redirected_to test with custom message

Created at 8 hours ago
jdufresne delete branch pre-commit-ci-update-config
Created at 10 hours ago
pull request closed
[pre-commit.ci] pre-commit autoupdate
Created at 10 hours ago

Allow specifying the HTTP status code in assert_redirected_to

Previously, the method always asserts the status is :redirect which allows for any kind of 3XX response. However, sometimes it is worthwhile to precise the status code of the redirect. For example, a Rails application may want to verify the redirect is a 301 (Moved Permanently) and not the default 302 (Found). The new method argument makes this convenient to do in one assertion.

Merge pull request #46057 from jdufresne/assert-redirect-status

Allow specifying the HTTP status code in assert_redirected_to

Created at 1 week ago
issue comment
Improve typography of user facing validation messages

Yes, this is changing the defaults and people can update their en.yml file to achieve this today.

However, good defaults matter and in this case, we can improve the defaults. Per the standard listed in the post, the current text is using the wrong Unicode character for a contraction. The current text requires every Rails developer that wants to follow the Unicode standard to override the default. That is unnecessary overhead for each project to take on when it can be fixed upstream.

Just like a spelling error, Rails developers could override the default, but that wouldn't hold back a fix.

Other software project and web frameworks do use the correct Unicode character for user facing strings.

Created at 1 week ago
delete branch
jdufresne delete branch assert-redirect-status
Created at 1 week ago

Add MIT-LICENSE file to Rails gem

Update docs for .unscoped to be explicit about associations

We recently ran into an issue where we used .unscoped as part of a method chain without realising that it would also unset the scoping of the association. It feels like this would be useful information to surface in the documentation so that there's a clear source of truth on how the method behaves.

Merge pull request #45502 from ehelms/add-license

Add MIT-LICENSE file to Rails gem

Don't delegate tasks to ActiveRecord::Base

This PR calls ActiveRecord::Base directly on establish_connection and connection rather than delegating. While this doesn't have much effect right now, I'm working on moving the database tasks away from their reliance on Base and eventually we'll need to pass a class through to these adapter tasks. This change prepares these adapter tasks for that change.

Register autoload for ActiveRecord::LogSubscriber

Before f56b4187be56304857b57ec7159a8e2dc2b91dea this constant was being loaded in the railtie, but it was removed since we didn't needed it anymore.

It causes some application to break if they try to reference the subscriber before ActiveRecord::Base is loaded.

Merge pull request #46067 from eileencodes/dont-delegate-tasks-to-base

Don't delegate tasks to ActiveRecord::Base

upgrade to QUnit 2 for ujs tests

Use a higher-level Sidekiq API for ActiveJob

This allows Sidekiq to use a custom client_class (rather than Sidekiq::Client), which is necessary for the new transaction-aware client in 6.5 (https://github.com/mperham/sidekiq/blob/main/Changes.md#650)

Do not run tests that have ensure instead of skip

Even if tests are "skipped" by Minitest::Assertions#skip ensure is executed because tests methods are Ruby methods.

Adding conditions outside of the test methods, entire test methods are executed only when they are necessary.

Use system(.., exception: true) for dummy apps

Related to #46064

Merge pull request #46083 from yahonda/follow_up_46064

Use system(.., exception: true) for dummy apps

Allow passing a class to dom_id

You no longer need to call new when passing a class to dom_id. This makes dom_id behave like dom_class in this regard. Apart from saving a few keystrokes, it prevents Ruby from needing to instantiate a whole new object just to generate a string.

Before:

dom_id(Post) # NoMethodError: undefined method `to_key' for Post:Class

After:

dom_id(Post) # "new_post"

You can still call dom_id(Post.new).

Merge pull request #46077 from lsylvester/qunit2

upgrade to QUnit 2 for UJS tests

Merge pull request #45770 from RyanMacG/update-docs-for-unscoped

Update docs for .unscoped to be explicit about associations

Merge pull request #46068 from goulvench/allow-passing-classes-to-dom_id

[FIX #46021] Allow passing classes to dom_id

Typo in error_reporting guide [ci-skip]

Merge pull request #46085 from olimart/patch-2

Typo in error_reporting guide [ci-skip]

Fix being able to pass --force to db:system:change

Running db:system:change will always prompt to overwrite database.yml, so being able to --force it seems expected

Merge pull request #46080 from jdelStrother/sidekiq-activejob

Use a higher-level Sidekiq API for ActiveJob

Communicate minimum Sidekiq version in its adapter

Created at 1 week ago
issue comment
Allow specifying the HTTP status code in assert_redirected_to

@byroot I applied the suggestion in the latest revision. Thanks for the review!

Created at 2 weeks ago

Use sslmode option instead of ssl_mode for MySQL command connections

In f36c261a44 support for the ssl-mode option was added for MySQL when using the dbconsole command and MySQLDatabaseTasks. However, the mysql2 gem uses ssl_mode instead of sslmode:

https://github.com/brianmario/mysql2/blob/ba4d46551d132492b34205cdb8fa224c92765bef/lib/mysql2/client.rb#L51

As ssl_mode is what should be used in the database.yml configuration for MySQL we should use it as well for the dbconsole command and MySQLDatabaseTasks.

Co-authored-by: Chris Gunther chris@room118solutions.com

Fix word case

windows -> Windows jruby -> JRuby

Merge pull request #46059 from jbampton/fix-word-case [ci-skip]

Fix word case

Fix word case. html -> HTML

Merge pull request #46060 from jbampton/fix-word-case-of-html

Fix word case. html -> HTML

Merge pull request #46058 from p8/fix-ssl-mode-option-for-mysql

Use sslmode option instead of ssl_mode for MySQL command connections

Improve error messages on bin/setup

system(.., exception: true) gives you more information on how the command failed, e.g.

bin/setup:8:in `system': Command failed with exit 1: bundle install (RuntimeError)

bin/setup:8:in `system': No such file or directory - bundle (Errno::ENOENT)

Adds test case for query cache false positive bug

Dup and freeze complex types when making query attributes

This avoids problems when complex data structures are mutated after being handed to ActiveRecord for processing. For example false hits in the query cache.

Fixes #46044

Merge pull request #46048 from rails/fix-hash-collisions

Dup and freeze complex types when making query attributes

Updating the ActiveRecord::Store and changing it back should not mark accessor as changed

Merge pull request #45645 from fatkodima/fix-store-dirty

Updating the ActiveRecord::Store and changing it back should not mark accessor as changed

Merge pull request #46064 from k0kubun/system-exception-true

Improve error messages on bin/setup

Created at 2 weeks ago

Use sslmode option instead of ssl_mode for MySQL command connections

In f36c261a44 support for the ssl-mode option was added for MySQL when using the dbconsole command and MySQLDatabaseTasks. However, the mysql2 gem uses ssl_mode instead of sslmode:

https://github.com/brianmario/mysql2/blob/ba4d46551d132492b34205cdb8fa224c92765bef/lib/mysql2/client.rb#L51

As ssl_mode is what should be used in the database.yml configuration for MySQL we should use it as well for the dbconsole command and MySQLDatabaseTasks.

Co-authored-by: Chris Gunther chris@room118solutions.com

Fix word case

windows -> Windows jruby -> JRuby

Merge pull request #46059 from jbampton/fix-word-case [ci-skip]

Fix word case

Fix word case. html -> HTML

Merge pull request #46060 from jbampton/fix-word-case-of-html

Fix word case. html -> HTML

Merge pull request #46058 from p8/fix-ssl-mode-option-for-mysql

Use sslmode option instead of ssl_mode for MySQL command connections

Improve error messages on bin/setup

system(.., exception: true) gives you more information on how the command failed, e.g.

bin/setup:8:in `system': Command failed with exit 1: bundle install (RuntimeError)

bin/setup:8:in `system': No such file or directory - bundle (Errno::ENOENT)

Adds test case for query cache false positive bug

Dup and freeze complex types when making query attributes

This avoids problems when complex data structures are mutated after being handed to ActiveRecord for processing. For example false hits in the query cache.

Fixes #46044

Merge pull request #46048 from rails/fix-hash-collisions

Dup and freeze complex types when making query attributes

Updating the ActiveRecord::Store and changing it back should not mark accessor as changed

Merge pull request #45645 from fatkodima/fix-store-dirty

Updating the ActiveRecord::Store and changing it back should not mark accessor as changed

Merge pull request #46064 from k0kubun/system-exception-true

Improve error messages on bin/setup

Allow specifying the HTTP status code in assert_redirected_to

Previously, the method always asserts the status is :redirect which allows for any kind of 3XX response. However, sometimes it is worthwhile to precise the status code of the redirect. For example, a Rails application may want to verify the redirect is a 301 (Moved Permanently) and not the default 302 (Found). The new method argument makes this convenient to do in one assertion.

Created at 2 weeks ago
pull request opened
Allow specifying the HTTP status code in assert_redirected_to

Previously, the method always asserts the status is :redirect which allows for any kind of 3XX response. However, sometimes it is worthwhile to precise the status code of the redirect. For example, a Rails application may want to verify the redirect is a 301 (Moved Permanently) and not the default 302 (Found). The new method argument makes this convenient to do in one assertion.

Checklist

Before submitting the PR make sure the following are checked:

  • [x] This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • [x] There are no typos in commit messages and comments.
  • [x] Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • [x] Feature branch is up-to-date with main (if not - rebase it).
  • [x] Pull request only contains one commit for bug fixes and small features. If it's a larger feature, multiple commits are permitted but must be descriptive.
  • [x] Tests are added if you fix a bug or add a feature.
  • [x] CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.
  • [x] PR is not in a draft state.
  • [x] CI is passing.
Created at 2 weeks ago

Allow specifying the HTTP status code in assert_redirected_to

Previously, the method always asserts the status is :redirect which allows for any kind of 3XX response. However, sometimes it is worthwhile to precise the status code of the redirect. For example, a Rails application may want to verify the redirect is a 301 (Moved Permanently) and not the default 302 (Found). The new method argument makes this convenient to do in one assertion.

Created at 2 weeks ago

Allow specifying the HTTP status code in assert_redirected_to

Previously, the method always asserted the status was :redirect, which allowed for any kind of 3XX response. However, sometimes it is worthwhile to precise the status code of the redirect. For example, a Rails application may want to verify the redirect is a 301 (Moved Permanently) and not the default 301 (Found). The new method argument makes this convenient to do in one assertion.

Created at 2 weeks ago

Allow specifying the HTTP status code in assert_redirected_to

Previously, the method always asserted the status was :redirect, which allowed for any kind of 3XX response. However, sometimes it is worthwhile to precise the status code of the redirect. For example, a Rails application may want to verify the redirect is a 301 (Moved Permanently) and not the default 301 (Found). The new method argument makes this convenient to do in one assertion.

Created at 2 weeks ago

Allow specifying the HTTP status code in assert_redirected_to

Previously, the method always asserted the status was :redirect, which allowed for any kind of 3XX response. However, sometimes it is worthwhile to precise the status code of the redirect. For example, a Rails application may want to verify the redirect is a 301 (Moved Permanently) and not the default 301 (Found). The new method argument makes this convention to do in one assertion.

Created at 2 weeks ago
create branch
jdufresne create branch assert-redirect-status
Created at 2 weeks ago

Add CHANGELOG entry for #45738 [ci-skip] (#46056)

Allow specifying the HTTP status code in assert_redirected_to

Previously, the method always asserted the status was :redirect, which allowed for any kind of 3XX response. However, sometimes it is worthwhile to precise the status code of the redirect. For example, an Rails application may want to verify the redirect is a 301 (Moved Permanently) and not the default 301 (Found). The new method argument makes this convention to do in one assertion.

Created at 2 weeks ago

Add CHANGELOG entry for #45738 [ci-skip] (#46056)

Created at 2 weeks ago

Include ActiveSupport::Testing::TaggedLogging for Rails >= 7

Define name to work around TaggedLogging

RSpec.current_example.metadata[:name] evaluates to nil by the time this is called.

Fixed typo

Merge pull request #2587 from rspec/shanecav84/include-tagged-logging

Include ActiveSupport::Testing::TaggedLogging for Rails >= 7 (rebased)

Created at 2 weeks ago

Encodes the uploaded file's headers - Closes #38080

Don't skip some columns in column_types on Postgres

Fixes https://github.com/rails/rails/issues/41651, by partially reverting https://github.com/rails/rails/pull/39097

I ran the same benchmark as https://github.com/rails/rails/pull/39097 and it seems like this change does not cause a perf regression.


require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "rails", path: "/Users/alex/code/rails" # github: "rails/rails", branch: "main"
  gem "sqlite3"
  gem "benchmark-ips"
end

require "active_record"

ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")

ActiveRecord::Schema.define do
  create_table :active_storage_blobs do |t|
    t.string   :key,          null: false
    t.string   :filename,     null: false
    t.string   :content_type
    t.text     :metadata
    t.string   :service_name, null: false
    t.bigint   :byte_size,    null: false
    t.string   :checksum,     null: false
    t.datetime :created_at,   null: false

    t.index [ :key ], unique: true
  end
end

class ActiveStorageBlob < ActiveRecord::Base
end

Benchmark.ips do |x|
  x.report("find_by") { ActiveStorageBlob.find_by(id: 1) }
end

This branch:

Warming up --------------------------------------
             find_by     1.940k i/100ms
Calculating -------------------------------------
             find_by     17.928k (± 4.8%) i/s -     91.180k in   5.098301s

Main:

Warming up --------------------------------------
             find_by     1.912k i/100ms
Calculating -------------------------------------
             find_by     17.961k (± 4.8%) i/s -     89.864k in   5.015252s

Explicitly list negative currency format

This makes it more clear for translators how to translate the negative format.

Add HTTP_REFERER when following redirects on integration tests

This makes a closer simulation of what happens in a real browser session

Move and rename rails-ujs files

For consistency with Action Cable and Active Storage, the source files are moved to app/javascript.

The files are also renamed in this commit (pre-conversion to javascript) so that git does a better job maintaining the history of the files.

Ref 7b0b372

Run decaffeinate on rails-ujs/*.js

Also run eslint --fix app/javascript with eslintrc from Active Storage

Address decaffeinate warnings

rails-ujs/start.js

  • Remove some implicit returns
  • Replace null checks with shorter variations

rails-ujs/features/confirm.js

  • Remove an implicit return
  • Add comment to empty catch block to fix eslint

rails-ujs/features/disable.js

  • Replace null checks with shorter variations
  • Remove an implicit return

rails-ujs/features/method.js

  • Replace null check with shorter version
  • Remove an implicit return

rails-ujs/features/remote.js

  • Remove some implicit returns

rails-ujs/utils/ajax.js

  • Rewrite null checks with shorter variations
  • Add comment to empty catch blocks to fix eslint

rails-ujs/utils/csp.js

  • Replace null checks with shorter variations
  • Rewrite code to not use guard

rails-ujs/utils/csrf.js

  • Rewrite null checks with shorter variations

rails-ujs/utils/dom.js

  • Replace null checks with shorter variations

rails-ujs/utils/events.js

  • Remove some implicit returns

rails-ujs/utils/form.js

  • Remove some implicit returns
  • Rewrite null check with shorter variation

Convert rails-ujs to ES2015 modules

Building and linting are setup similar to other packages

Most of the changes are related to converting from sprockets requires to ESM imports/export. However, there are a few notable changes as well:

  • A few methods have been refactored to store the Rails object in a closure so that properties on it can be overriden by applications (as documented and tested). This also resulted in the "start" module getting inlined so that it can use the resulting functions.

  • The logic for running Rails.start() automatically had to change because Rollup uses a slightly different module format than the previous coffeescript bundle. The Rollup bundle does not set window.Rails until the end up the bundle, so the condition had to be updated and window.Rails had to be set manually to ensure backwards compatability with scripts listening to the rails:attachBindings event

Update Pull Request Template

The major change is to add checklist so that it's easier to be read than comments. Also, Summary is not clear about what should be written, so here it's changed to Motivation and Detail. Finally, it clearly says they can discard this template if they need to.

update ContentAttachment so that it works with "content" attributes

this makes it possible for an application to embed markup in a document that would otherwise be undesirable or expensive to process. For example, an incoming email may include a complicated bit of DOM in a quote, and while you don't want to have to process and rewrite it, you also don't want to discard it; the content attribute of ContentAttachment allows you to make that work.

update CHANGELOG

ContentAttachment is an internal API; let's indicate that with :nodoc:

linter appeasement

make sure rendering the content attachment actually works

Deprecate quoting ActiveSupport::Duration as an integer

Fixes a defect in ActiveModel::Dirty#attribute_changed? where the :from and :to options are not being type cast. For example, for an enum attribute, attribute_changed? should handle a String, Symbol or Integer for the :from and :to options.

Optimize AS::LogSubscriber

The various LogSubscriber subclasses tend to subscribe to events but then end up doing nothing if the log level is high enough.

But even if we end up not logging, we have to go through the entire notification path, record timing etc.

By allowing subscribers to dynamically bail out early, we can save a lot of work if all subscribers are silenced.

Nested attribute docs improvements

2 small improvemennts to the docs for ActiveRecord::NestedAttributes.

  • Include a link to ActionView::Helpers::FormHelper::fields_for, since you would typically use these tools in tandem I think it makes sense to point you to it.
  • Show an example of how to write an integration test when using ActionView::Helpers::FormHelper::fields_for. You could argue that this example should also go in Action View, but I think it makes more sense here as the "parent" doc for the Nested Attributes feature.

Update activerecord/lib/active_record/nested_attributes.rb

Co-authored-by: Petrik de Heus petrik@deheus.net

Do not return CSP headers for 304 Not Modified responses

Created at 2 weeks ago

Encodes the uploaded file's headers - Closes #38080

Don't skip some columns in column_types on Postgres

Fixes https://github.com/rails/rails/issues/41651, by partially reverting https://github.com/rails/rails/pull/39097

I ran the same benchmark as https://github.com/rails/rails/pull/39097 and it seems like this change does not cause a perf regression.


require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "rails", path: "/Users/alex/code/rails" # github: "rails/rails", branch: "main"
  gem "sqlite3"
  gem "benchmark-ips"
end

require "active_record"

ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")

ActiveRecord::Schema.define do
  create_table :active_storage_blobs do |t|
    t.string   :key,          null: false
    t.string   :filename,     null: false
    t.string   :content_type
    t.text     :metadata
    t.string   :service_name, null: false
    t.bigint   :byte_size,    null: false
    t.string   :checksum,     null: false
    t.datetime :created_at,   null: false

    t.index [ :key ], unique: true
  end
end

class ActiveStorageBlob < ActiveRecord::Base
end

Benchmark.ips do |x|
  x.report("find_by") { ActiveStorageBlob.find_by(id: 1) }
end

This branch:

Warming up --------------------------------------
             find_by     1.940k i/100ms
Calculating -------------------------------------
             find_by     17.928k (± 4.8%) i/s -     91.180k in   5.098301s

Main:

Warming up --------------------------------------
             find_by     1.912k i/100ms
Calculating -------------------------------------
             find_by     17.961k (± 4.8%) i/s -     89.864k in   5.015252s

Explicitly list negative currency format

This makes it more clear for translators how to translate the negative format.

Add HTTP_REFERER when following redirects on integration tests

This makes a closer simulation of what happens in a real browser session

Move and rename rails-ujs files

For consistency with Action Cable and Active Storage, the source files are moved to app/javascript.

The files are also renamed in this commit (pre-conversion to javascript) so that git does a better job maintaining the history of the files.

Ref 7b0b372

Run decaffeinate on rails-ujs/*.js

Also run eslint --fix app/javascript with eslintrc from Active Storage

Address decaffeinate warnings

rails-ujs/start.js

  • Remove some implicit returns
  • Replace null checks with shorter variations

rails-ujs/features/confirm.js

  • Remove an implicit return
  • Add comment to empty catch block to fix eslint

rails-ujs/features/disable.js

  • Replace null checks with shorter variations
  • Remove an implicit return

rails-ujs/features/method.js

  • Replace null check with shorter version
  • Remove an implicit return

rails-ujs/features/remote.js

  • Remove some implicit returns

rails-ujs/utils/ajax.js

  • Rewrite null checks with shorter variations
  • Add comment to empty catch blocks to fix eslint

rails-ujs/utils/csp.js

  • Replace null checks with shorter variations
  • Rewrite code to not use guard

rails-ujs/utils/csrf.js

  • Rewrite null checks with shorter variations

rails-ujs/utils/dom.js

  • Replace null checks with shorter variations

rails-ujs/utils/events.js

  • Remove some implicit returns

rails-ujs/utils/form.js

  • Remove some implicit returns
  • Rewrite null check with shorter variation

Convert rails-ujs to ES2015 modules

Building and linting are setup similar to other packages

Most of the changes are related to converting from sprockets requires to ESM imports/export. However, there are a few notable changes as well:

  • A few methods have been refactored to store the Rails object in a closure so that properties on it can be overriden by applications (as documented and tested). This also resulted in the "start" module getting inlined so that it can use the resulting functions.

  • The logic for running Rails.start() automatically had to change because Rollup uses a slightly different module format than the previous coffeescript bundle. The Rollup bundle does not set window.Rails until the end up the bundle, so the condition had to be updated and window.Rails had to be set manually to ensure backwards compatability with scripts listening to the rails:attachBindings event

Update Pull Request Template

The major change is to add checklist so that it's easier to be read than comments. Also, Summary is not clear about what should be written, so here it's changed to Motivation and Detail. Finally, it clearly says they can discard this template if they need to.

update ContentAttachment so that it works with "content" attributes

this makes it possible for an application to embed markup in a document that would otherwise be undesirable or expensive to process. For example, an incoming email may include a complicated bit of DOM in a quote, and while you don't want to have to process and rewrite it, you also don't want to discard it; the content attribute of ContentAttachment allows you to make that work.

update CHANGELOG

ContentAttachment is an internal API; let's indicate that with :nodoc:

linter appeasement

make sure rendering the content attachment actually works

Deprecate quoting ActiveSupport::Duration as an integer

Fixes a defect in ActiveModel::Dirty#attribute_changed? where the :from and :to options are not being type cast. For example, for an enum attribute, attribute_changed? should handle a String, Symbol or Integer for the :from and :to options.

Optimize AS::LogSubscriber

The various LogSubscriber subclasses tend to subscribe to events but then end up doing nothing if the log level is high enough.

But even if we end up not logging, we have to go through the entire notification path, record timing etc.

By allowing subscribers to dynamically bail out early, we can save a lot of work if all subscribers are silenced.

Nested attribute docs improvements

2 small improvemennts to the docs for ActiveRecord::NestedAttributes.

  • Include a link to ActionView::Helpers::FormHelper::fields_for, since you would typically use these tools in tandem I think it makes sense to point you to it.
  • Show an example of how to write an integration test when using ActionView::Helpers::FormHelper::fields_for. You could argue that this example should also go in Action View, but I think it makes more sense here as the "parent" doc for the Nested Attributes feature.

Update activerecord/lib/active_record/nested_attributes.rb

Co-authored-by: Petrik de Heus petrik@deheus.net

Do not return CSP headers for 304 Not Modified responses

Created at 2 weeks ago
create tag
jdufresne create tag v6.0.6
Created at 2 weeks ago
create tag
jdufresne create tag v7.0.4
Created at 2 weeks ago
create tag
jdufresne create tag v6.1.7
Created at 2 weeks ago