Commit Graph

81032 Commits

Author SHA1 Message Date
Jean Boussier 75a864c2b6
Merge pull request #42889 from santib/fix-nodoc
Fix :nodoc: [ci skip]
2021-07-27 22:35:56 +02:00
Santiago Bartesaghi 92f12d77c4 Fix :nodoc: [ci skip] 2021-07-27 16:52:58 -03:00
Jorge Manrubia a29884d733 Remove mechanism to disable test parallelization when runnin gonly 1 test
#42761 made the old system of disable paralleling testing when
only one test file was included obsolete.
2021-07-27 10:33:09 -07:00
Jonathan Hefner 71cbc9150f
Merge pull request #42885 from santib/fix-instrumentation-guides
Remove empty section from the instrumentation guides [ci skip]
2021-07-27 11:00:45 -05:00
Santiago Bartesaghi 905d20bc8a Improve sections on instrumentation guides [ci skip] 2021-07-27 12:42:43 -03:00
Jean Boussier 4cc602c02f
Merge pull request #42881 from etiennebarrie/fix-current-attributes-test-leak
Remove leak when using CurrentAttributes in thread variables
2021-07-27 12:25:40 +02:00
Étienne Barrié 39b382cf78 Remove leak when using CurrentAttributes in thread variables
The test for CurrentAttributes using thread-local variables leaks
an instance in Thread.current.

Usually instances are reset in the test helper but the objects remain:
activesupport/lib/active_support/current_attributes/test_helper.rb:11

In this situation we use clear_all to make sure we don't leave instances
behind when the configuration is changed.
2021-07-27 11:50:37 +02:00
Eugene Kenny 85e4ac6f86
Merge pull request #42853 from jonathanhefner/guides-clipboard-text-attribute
Render copy-to-clipboard text in element attribute [ci-skip]
2021-07-27 08:50:54 +01:00
Eugene Kenny cca3911c16
Merge pull request #42860 from dixpac/dix/remove_deprecated_time_zone_initializer
FIX: Setting remove_deprecated_time_with_zone_name in new framework defaults
2021-07-27 08:36:35 +01:00
David Heinemeier Hansson 9c73d4aeab
Make Action Text + Trix JS/CSS available via the asset pipeline (#42857)
* Action Text JS should be available via the asset pipeline too

* Main was a module anyway, no need to reference that twice

* Fix rollup references

* Precompile action text JS for asset pipeline

* No JavaScript dependencies needed with the asset pipeline

* Stub Webpacker::Engine to trigger webpack path for testing

* Extract asset paths

* Exercise asset pipeline path

* Terser doesn't do anything useful on this small package

* Make trix directly available to the asset pipeline

* Indirect doesn't carry its worth

* Reminder for development about keeping things in sync for the asset pipeline

* Ensure this isn't turned into undefined while mirroring

* Mirror Trix CSS for asset pipeline

* Add the needed JS include tag automatically under the asset pipeline

* Please RuboCop

* Keep the peer dependency

Even though we also need it explicitly as a dev dependency in order to generate the mirror output for trix.

* Fix test

* Add CHANGELOG entry
2021-07-26 18:57:42 -04:00
Jonathan Hefner e9ed23786d
Merge pull request #42876 from AkhilGKrishnan/guides-grammer-issue-fix
Active job basic doc grammatical mistakes fixed [ci-skip]

Co-authored-by: Petrik de Heus <petrik@deheus.net>
2021-07-26 12:19:53 -05:00
akhilgkrishnan bf79a4c8e2 Active job basic doc grammer mistakes fixed 2021-07-26 22:41:20 +05:30
Eugene Kenny 25f6a8e84f
Merge pull request #42809 from eugeneius/rm_request_response_requires
Don't require ActionDispatch::{Request,Response}
2021-07-26 02:06:02 +01:00
Eugene Kenny e9b7403bb9
Merge pull request #42808 from eugeneius/log_rescued_responses_env_config
Pass log_rescued_responses as environment config
2021-07-26 02:05:48 +01:00
Ryuta Kamizono 1488cb8440
Merge pull request #42863 from georgeclaghorn/rm-outdated-comment
Remove outdated comment in `ActiveRecord::Associations::AssociationScope#add_constraints`
2021-07-25 17:39:09 +09:00
George Claghorn 3fa7dce079 Remove outdated comment in ActiveRecord::Associations::AssociationScope#add_constraints [ci skip]
This comment was correct when it was added in 65843e1. In that commit, ActiveRecord::AssociationScope#scope applies the nearest association's scope, and #add_constraints skips it.

c8d8899 made the comment incorrect. It modified #scope not to apply the nearest association's scope and #add_constraints to apply scopes for the entire association chain.
2021-07-24 17:55:01 -04:00
Dino Maric a6c0e84f02 FIX: Setting remove_deprecated_time_with_zone_name in new framework defaults
Setting `remove_deprecated_time_with_zone_name` didn't work because
the value is checked in a framework initialiser, which runs before application initialiser.

This PR moves the setting inside the `config.after_initialize` block.
I've also added 2 tests for this behaviour.

Fixes #42820
2021-07-24 16:47:49 +02:00
Ryuta Kamizono 2a6459d8ca
Merge pull request #42855 from kamipo/fix_to_json
Fix `to_json` after `changes_applied` for `ActiveModel::Dirty` object
2021-07-24 08:38:23 +09:00
Ryuta Kamizono 0f001f00eb Fix `to_json` after `changes_applied` for `ActiveModel::Dirty` object
Follow up to #41677.

Mutation tracking variables are not only `@mutations_from_database` but
also `@mutations_before_last_save`.
2021-07-24 08:22:18 +09:00
Ryuta Kamizono 6abe728e1d
Merge pull request #42854 from jonathanhefner/current_page-with-trailing-slash
Fix current_page? when URL has trailing slash
2021-07-24 08:00:02 +09:00
Jonathan Hefner 8ace007519 Fix current_page? when URL has trailing slash
This fixes the `current_page?` helper when the given URL has a trailing
slash, and is an absolute URL or also has query params.

Fixes #33956.

Co-authored-by: Rien Maertens <rien.maertens@posteo.be>
2021-07-23 17:03:45 -05:00
Jonathan Hefner baa070c3b4
Merge pull request #42839 from jonathanhefner/doc-each_validator
Remove nodoc from EachValidator [ci-skip]
2021-07-23 13:27:35 -05:00
Jonathan Hefner b78966b558 Render copy-to-clipboard text in element attribute [ci-skip]
Rendering copy-to-clipboard text in an invisible element causes
invisible extraneous matches when searching text on the page (e.g. with
Ctrl+F).  Rendering in an element attribute avoids this problem.
2021-07-23 12:52:10 -05:00
Jean Boussier 5db5de5341
Merge pull request #42845 from jonathanhefner/fix-descendants-garbage-collection-test
Isolate descendants garbage collection test
2021-07-23 18:11:33 +02:00
Jean Boussier 8512118f43
Merge pull request #42832 from lulalala/slim-errors-inspect
Slimmer ActiveModel::Errors#inspect message
2021-07-23 09:05:08 +02:00
lulalala 1523838567 Slimmer ActiveModel::Errors#inspect
Only show @errors array and hide @base
2021-07-23 12:29:46 +08:00
Ryuta Kamizono 93b16e71f9
Merge pull request #42842 from jonathanhefner/fix-file-update-checker-test-double-waits
Avoid double wait in EventedFileUpdateCheckerTest
2021-07-23 12:34:01 +09:00
Jonathan Hefner 5ce985ac9b
Merge pull request #42825 from brianknight10/guides/add-host-configuration-values
Add host authorization middleware options to the config guide [ci-skip]
2021-07-22 20:43:17 -05:00
Brian Knight a70c7a2f53
Add host authorization middleware options to the config guide 2021-07-22 21:25:38 -04:00
eileencodes 77e5f91f42
Merge branch 'opt_into_open_redirect_protection' 2021-07-22 16:54:36 -04:00
Jonathan Hefner 60fc40ea58 Isolate descendants garbage collection test
This prevents the test from being affected by Ruby-internal thread
locals set by other tests.

Example failure: https://buildkite.com/rails/rails/builds/79505#cb261462-8e40-4adc-99fc-81708a473cc6/1076-1085

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2021-07-22 14:32:22 -05:00
Gannon McGibbon 5e93cff835
Raise error on unpermitted open redirects.
Add `allow_other_host` options to `redirect_to`.
Opt in to this behaviour with `ActionController::Base.raise_on_open_redirects = true`.
2021-07-22 14:03:59 -04:00
Jean Boussier 25d8c1ce45
Merge pull request #42831 from marcelolx/fix_dirty_check_for_nan
Fix dirty check for Float::NaN and BigDecimal::NaN
2021-07-22 20:00:35 +02:00
Jonathan Hefner 86c732a606 Avoid double wait in EventedFileUpdateCheckerTest
Waiting after touching the file system is a concern of
`EventedFileUpdateCheckerTest`.  Therefore, only call `wait` inside
`EventedFileUpdateCheckerTest`.  This avoids calling `wait` an extra
time when calling `touch`.

Before:

    $ bin/test test/evented_file_update_checker_test.rb test/file_update_checker_test.rb

    Finished in 43.357019s, 0.9918 runs/s, 2.5371 assertions/s.
    43 runs, 110 assertions, 0 failures, 0 errors, 0 skips

After:

    $ bin/test test/evented_file_update_checker_test.rb test/file_update_checker_test.rb

    Finished in 34.351007s, 1.2518 runs/s, 3.2022 assertions/s.
    43 runs, 110 assertions, 0 failures, 0 errors, 0 skips
2021-07-22 12:29:27 -05:00
Jonathan Hefner 79bb7d0a2b Remove nodoc from EachValidator [ci-skip]
The Active Record Validations guide recommends using `EachValidator`,
and has done so for many years.
2021-07-22 10:35:48 -05:00
Jean Boussier fcacb93295
Merge pull request #39428 from etiennebarrie/thread-local-current-attributes
Allow using thread variables for CurrentAttributes instances
2021-07-22 16:40:10 +02:00
Marcelo Lauxen d1df4c100f
Fix dirty check for Float::NaN and BigDecimal::NaN
Float::NaN and BigDecimal::NaN in Ruby are [special values](https://bugs.ruby-lang.org/issues/1720) and can't be compared with `==`.
2021-07-22 09:49:16 -03:00
Jean Boussier 212077a972
Merge pull request #42833 from Shopify/fix-memcached-6.1-local-store
MemCacheStore: Properly duplicate local cache values in 6.1 mode
2021-07-21 22:03:02 +02:00
Jean Boussier 733774f35e MemCacheStore: Properly duplicate local cache values in 6.1 mode
Followup: https://github.com/rails/rails/pull/42649

I found a way to preserve the `deep_dup` behavior in 6.1 mode.
So we no longer need to skip these tests.
2021-07-21 17:55:09 +02:00
Étienne Barrié 8195cd5f99 Allow using thread variables for CurrentAttributes instances 2021-07-21 16:53:32 +02:00
Ryuta Kamizono 5d78c54a46
Merge pull request #42829 from yahonda/diag79471
Address FixturesWithForeignKeyViolationsTest#test_does_not_raise_if_no_fk_violations error
2021-07-21 18:05:10 +09:00
Eugene Kenny 8dab534ca8
Merge pull request #42827 from jdufresne/author-id
Correct Inflector.humanize keep_id_suffix argument docs
2021-07-21 08:56:35 +01:00
Yasuo Honda d481d08449 Address FixturesWithForeignKeyViolationsTest#test_does_not_raise_if_no_fk_violations
Managed to reproduce CI failure at https://buildkite.com/rails/rails/builds/79496#0c03f856-9be1-4ca0-88c9-e1df21ae0a07

This commitaddresses the following errors by loading :author_addresses fixture because
`:authors` has a foreign key to `:author_addresses`.

* sqlite3 adapter
```ruby
$ bin/test test/cases/adapters/sqlite3/explain_test.rb test/cases/fixtures_test.rb -n "/^(?:SQLite3ExplainTest#(?:test_explain_with_eager_loading)|FixturesWithForeignKeyViolationsTest#(?:test_does_not_raise_if_no_fk_violations))$/" --seed 2529
Using sqlite3
Run options: -n "/^(?:SQLite3ExplainTest#(?:test_explain_with_eager_loading)|FixturesWithForeignKeyViolationsTest#(?:test_does_not_raise_if_no_fk_violations))$/" --seed 2529

.E

Error:
FixturesWithForeignKeyViolationsTest#test_does_not_raise_if_no_fk_violations:
RuntimeError: Foreign key violations found in your fixture data. Ensure you aren't referring to labels that don't exist on associations.
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/fixtures.rb:641:in `block in insert'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/fixtures.rb:629:in `each'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/fixtures.rb:629:in `insert'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/fixtures.rb:615:in `read_and_insert'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/fixtures.rb:567:in `create_fixtures'
    /home/yahonda/src/github.com/rails/rails/activerecord/test/cases/fixtures_test.rb:844:in `block (2 levels) in test_does_not_raise_if_no_fk_violations'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/testing/assertions.rb:34:in `assert_nothing_raised'
    /home/yahonda/src/github.com/rails/rails/activerecord/test/cases/fixtures_test.rb:843:in `block in test_does_not_raise_if_no_fk_violations'
    /home/yahonda/src/github.com/rails/rails/activerecord/test/cases/fixtures_test.rb:857:in `with_verify_foreign_keys_for_fixtures'
    /home/yahonda/src/github.com/rails/rails/activerecord/test/cases/fixtures_test.rb:842:in `test_does_not_raise_if_no_fk_violations'

bin/test test/cases/fixtures_test.rb:835

Finished in 0.045767s, 43.6991 runs/s, 174.7966 assertions/s.
2 runs, 8 assertions, 0 failures, 1 errors, 0 skips
$
```

* postgresql adapter

```ruby
$ ARCONN=postgresql bin/test test/cases/adapters/postgresql/explain_test.rb test/cases/fixtures_test.rb -n "/^(?:PostgreSQLExplainTest#(?:test_explain_with_eager_loading)|FixturesWithForeignKeyViolationsTest#(?:test_does_not_raise_if_no_fk_violations))$/" --seed 16926
Using postgresql
Run options: -n "/^(?:PostgreSQLExplainTest#(?:test_explain_with_eager_loading)|FixturesWithForeignKeyViolationsTest#(?:test_does_not_raise_if_no_fk_violations))$/" --seed 16926

.E

Error:
FixturesWithForeignKeyViolationsTest#test_does_not_raise_if_no_fk_violations:
RuntimeError: Foreign key violations found in your fixture data. Ensure you aren't referring to labels that don't exist on associations.
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/fixtures.rb:641:in `block in insert'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/fixtures.rb:629:in `each'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/fixtures.rb:629:in `insert'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/fixtures.rb:615:in `read_and_insert'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/fixtures.rb:567:in `create_fixtures'
    /home/yahonda/src/github.com/rails/rails/activerecord/test/cases/fixtures_test.rb:844:in `block (2 levels) in test_does_not_raise_if_no_fk_violations'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/testing/assertions.rb:34:in `assert_nothing_raised'
    /home/yahonda/src/github.com/rails/rails/activerecord/test/cases/fixtures_test.rb:843:in `block in test_does_not_raise_if_no_fk_violations'
    /home/yahonda/src/github.com/rails/rails/activerecord/test/cases/fixtures_test.rb:857:in `with_verify_foreign_keys_for_fixtures'
    /home/yahonda/src/github.com/rails/rails/activerecord/test/cases/fixtures_test.rb:842:in `test_does_not_raise_if_no_fk_violations'

bin/test test/cases/fixtures_test.rb:835

Finished in 0.121193s, 16.5027 runs/s, 49.5080 assertions/s.
2 runs, 6 assertions, 0 failures, 1 errors, 0 skips
$
```

* It does not reproduce with mysql2 adapter because MySQL does not have
  features to validate existing foreign keys, but added
  :author_addresses in Mysql2ExplainTest for consistency.

Follow up #42674
2021-07-21 16:54:35 +09:00
Jean Boussier 48f4c88214 Fix changelog entry for active_record.partial_inserts 2021-07-21 09:12:36 +02:00
Jean Boussier 17db990ed0
Merge pull request #42649 from Shopify/local-cache-refactor
Refactor local cache to avoid serializing entries twice
2021-07-21 08:56:09 +02:00
Jon Dufresne a4a8478801 Correct Inflector.humanize keep_id_suffix argument docs
The "id" word is not capitalized. Observe:

    irb(main):001:0> ActiveSupport::Inflector.humanize('author_id', keep_id_suffix: true)
    => "Author id"
2021-07-20 20:42:27 -07:00
Guillermo Iguaran e43d0ddb03
Merge pull request #42790 from YusukeIwaki/replace_poltergeist_with_cuprite
Deprecate `poltergeist` and `webkit` driver registration. Add `cuprite`.
2021-07-20 18:14:58 -07:00
Ryuta Kamizono e50b0e3ab3 Fixup CHANGELOGs [ci skip] 2021-07-21 10:08:08 +09:00
YusukeIwaki e489b2467b Deprecate :poltergeist, :webkit instead of removing. 2021-07-21 09:52:34 +09:00
YusukeIwaki 5372459aa4 Remove `poltergeist` and `webkit` driver registration logics in system testing. Add `cuprite` instead.
Poltergeist and capybara-webkit are already not maintained.

* https://github.com/teampoltergeist/poltergeist
* https://github.com/thoughtbot/capybara-webkit

Most users actually use Selenium with Headless Chrome in these years, and it is not encouraged to use poltergeist or capybara-webkit at this moment.

Cuprite is a good alternative driver to Poltergeist: https://evilmartians.com/chronicles/system-of-a-test-setting-up-end-to-end-rails-testing
Not only removing deprecated Capybara drivers, also introducing Cuprite.
2021-07-21 09:52:29 +09:00