Commit Graph

8626 Commits

Author SHA1 Message Date
Akhil G Krishnan 8ae0b4ac7a [skip ci] Testing by line range documentation added in guide
Review changes updated

Update railties/lib/rails/commands/test/USAGE

Co-authored-by: Yasuo Honda <yasuo.honda@gmail.com>

Update guides/source/testing.md

Co-authored-by: Yasuo Honda <yasuo.honda@gmail.com>
2023-08-15 07:40:17 +05:30
Josephine 03f5f45615
Reference correct method from 'deliver_now' example code 2023-08-11 07:11:16 -07:00
r7kamura 7f52979f0a Remove unnecessary isolation_level setting from load_defaults 7.0
The default value of `ActiveSupport::IsolatedExecutionState.isolation_level` is set to `:thread`, regardless of whether `load_defaults 7.0` is used or not.

- https://github.com/rails/rails/blob/v7.0.4/activesupport/lib/active_support/isolated_execution_state.rb

If so, there is no need to set this in `load_defaults 7.0`. This Pull Request has been created to remove this unnecessary setting
2023-08-09 14:39:38 +09:00
Akhil G Krishnan a46f4c28c1 Removes Webpacker from the guides index page
webpacker file removed
2023-08-08 23:02:36 +05:30
Sean Doyle b1db663a12 Active Storage Guides: change `fixture_file_upload` to `file_fixture_upload`
Follow-up to [#48857][]

Mention the recently introduced `file_fixture_upload` alias in the
Active Storage Overview guides to reinforce the symmetry with the
`file_fixture` test helper method.

[#48857]: https://github.com/rails/rails/pull/48857

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-08-06 13:10:40 -05:00
Rafael Mendonça França 73cb71b9af
Link to the API and let the documentation generator point to edge 2023-08-04 16:54:56 -04:00
Sean Doyle 6cafc49d2c Rename `fixture_file_upload` method to `file_fixture_upload`
The naming difference between the test harness' [file_fixture][] helper
made available through Active Support (along with the
`file_fixture_path` configuration value) and the integration test
harness' [fixture_file_upload][] is a constant source of confusion and
surprise.

Since Active Support is more ubiquitous, this commit renames the
`fixture_file_upload` method to `file_fixture_upload` to match the order
of words in `file_fixture` and `file_fixture_path`.

To preserve backwards compatibility, declare a `fixture_file_upload`
alias to be preserved into the future (or removed at a future point in
time).

[file_fixture]: https://edgeapi.rubyonrails.org/classes/ActiveSupport/Testing/FileFixtures.html#method-i-file_fixture
[fixture_file_upload]: https://edgeapi.rubyonrails.org/classes/ActionDispatch/TestProcess/FixtureFile.html#method-i-fixture_file_upload
2023-08-04 12:40:17 -04:00
Jack CP aaf844af73 Fix typo in ActiveRecord Query guide
The SQL generated by this query (at 13.1.3.2):

```ruby
Author.joins(books: [{ reviews: { customer: :orders } }, :supplier] )
```

Is said to generate SQL whose select list is comprised of `*`, not
`authors.*`
2023-08-04 17:20:02 +12:00
Mike Dalessio bfeb580264
Introduce config.dom_testing_default_html_version
which controls the HTML parser used by rails-dom-testing assertions.

The config parameter is set to :html5 in Rails 7.1 if the Nokogiri
HTML5 parser is supported.
2023-08-03 11:16:52 -04:00
Akhil G Krishnan c0b850ab92 [skip ci] Added missing parathesis in guide 2023-08-03 19:30:25 +05:30
Rafael Mendonça França e980f158a4
Merge pull request #48847 from seanpdoyle/omit-webdrivers-from-gemfile-template
Omit `webdrivers` gem from `Gemfile` template
2023-08-02 13:49:28 -04:00
Rafael Mendonça França 3f500d7937
Merge pull request #48806 from akhilgkrishnan/punctuation-and-grammer-fix
[skip ci] Added some grammatical changes and missing punctuations
2023-08-01 18:07:34 -04:00
Akhil G Krishnan 73e6ddc273 [skip ci] Added some grammatical changes and puntuations
fixed the line length

Alignment fix

Alignment fix

Update guides/source/active_record_multiple_databases.md

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>

Update guides/source/active_record_multiple_databases.md

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>

Update guides/source/active_record_multiple_databases.md

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>

Update guides/source/active_record_multiple_databases.md

Co-authored-by: Alex Ghiculescu <alex@tanda.co>

updated essential with important
2023-08-01 23:32:07 +05:30
Akhil G Krishnan f171101f17 Fixed few typos in tests and guide
reverted the unwanted change

fixed the alignment

review changes updated
2023-08-01 23:31:17 +05:30
Sean Doyle 9a53234695 Omit `webdrivers` gem from `Gemfile` template
As of Selenium 4.6, [the Selenium Manager is capable of managing Chrome
Driver installations and integrations][readme]. As of Selenium 4.11, the
Selenium Manager is capable of [capable of resolving the Chrome for
Testing installation][] path.

By omitting the `gem` declaration from the `Gemfile.tt`, newly generated
applications and applications updating their `Gemfile` in lockstep with
newer Rails versions can shed the dependency and avoid test failures
introduced by newly released Chrome versions (like, for example,
[titusfortner/webdrivers#247][]).

[readme]: 43f8ac436c (update-selenium-manager)
[titusfortner/webdrivers#247]: https://github.com/titusfortner/webdrivers/issues/247
[capable of resolving the Chrome for Testing installation]: https://github.com/rails/rails/pull/48847#issuecomment-1656756862

Co-authored-by: Titus Fortner <titusfortner@users.noreply.github.com>
2023-08-01 09:22:08 -04:00
soartec-lab c8985995a7 Update `listen` gem version in guide [skip ci] 2023-07-29 16:15:56 +09:00
Jonathan Hefner 36f9cfdd90 Lazily deserialize cache entries
This adds a cache optimization such that expired and version-mismatched
cache entries can be detected without deserializing their values.  This
optimization is enabled when using cache format version >= 7.1 or a
custom serializer.

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2023-07-27 14:58:35 -05:00
Jonathan Hefner 3efb84486e Support replacing cache compressor
This commit adds support for replacing the compressor used for
serialized cache entries.  Custom compressors must respond to `deflate`
and `inflate`.  For example:

  ```ruby
  module MyCompressor
    def self.deflate(string)
      # compression logic...
    end

    def self.inflate(compressed)
      # decompression logic...
    end
  end

  config.cache_store = :redis_cache_store, { compressor: MyCompressor }
  ```

As part of this work, cache stores now also support a `:serializer`
option.  Similar to the `:coder` option, serializers must respond to
`dump` and `load`. However, serializers are only responsible for
serializing a cached value, whereas coders are responsible for
serializing the entire `ActiveSupport::Cache::Entry` instance.
Additionally, the output from serializers can be automatically
compressed, whereas coders are responsible for their own compression.

Specifying a serializer instead of a coder also enables performance
optimizations, including the bare string optimization introduced by cache
format version 7.1.
2023-07-26 11:59:09 -05:00
Akhil G Krishnan f4233f5bd0 [ci skip] Add --skip-dev-gems rails command line argument to the guide 2023-07-24 12:57:01 +05:30
Santiago Bartesaghi 76da537a39 [ci skip] ActiveStorage guides don't recommend using a deprecated config 2023-07-21 16:11:23 -03:00
Dave Powers f7c5e7e75c
Improve readability of case sensitivity description 2023-07-20 16:30:16 -04:00
Adrianna Chang 0ccde297a1
Merge pull request #48752 from wildmaples/patch-1
Use different bucket name in AS Guide for clarity
2023-07-20 12:06:42 -04:00
Maple Ong 3fd850fe0b [ci skip] Use different bucket name for clarity
Currently the service specified here is `:s3` and it could be confused for the `Service::S3Service`. The modified code example shows more clarity to the reader that the service in this case here refers to the bucket name outlined in `storage.yml` rather than the adapter service.
2023-07-20 09:38:37 -04:00
Shunichi Ikegami ea8795040e Fix ActiveStorage Overview CORS examples.
S3 CORS configuration's `ExposeHeaders` corresponds to Access-Control-Expose-Headers that indicates which **response** headers should be made available to scripts running in the browser.
But current example contains **request** headers (e.g. Content-MD5).
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers

`AllowedHeaders` corresponds to Access-Control-Allow-Headers that indicates which **request** headers is allowed.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers

Additionally, `Origin` is not required in Access-Control-Allow-Headers.
User agents automatically add the Origin request header to CORS request and JS can't control it's behavior.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin
2023-07-19 19:00:37 +09:00
Yasuo Honda 93453aaf23
Merge pull request #48728 from ghiculescu/patch-11
Improve AR Encryption docs
2023-07-18 22:49:59 +09:00
Ron Shinall aba723bffb Fix documentation error for Delegated Types 2023-07-13 13:34:15 -06:00
Dan Arnfield 95b2add89e Document common ActiveStorage issues
* How to keep existing attachments on a has_many_attached when uploading new ones
* How to retain uploaded files when a form submission fails validation
[ci skip]
2023-07-13 09:19:27 -05:00
Alex Ghiculescu cdebf39e6c
Improve AR Encryption docs 2023-07-13 16:30:22 +10:00
Jean Boussier 7b52f569c1
Merge pull request #48600 from Shopify/transaction-commit-on-return
Active Record commit transaction on `return`, `break` and `throw`
2023-07-10 10:55:41 +02:00
Jean Boussier 5fbaa524b9 Active Record commit transaction on `return`, `break` and `throw`
Fix: https://github.com/rails/rails/issues/45017
Ref: https://github.com/rails/rails/pull/29333
Ref: https://github.com/ruby/timeout/pull/30

Historically only raised errors would trigger a rollback, but in Ruby `2.3`, the `timeout` library
started using `throw` to interupt execution which had the adverse effect of committing open transactions.

To solve this, in Active Record 6.1 the behavior was changed to instead rollback the transaction as it was safer
than to potentially commit an incomplete transaction.

Using `return`, `break` or `throw` inside a `transaction` block was essentially deprecated from Rails 6.1 onwards.

However with the release of `timeout 0.4.0`, `Timeout.timeout` now raises an error again, and Active Record is able
to return to its original, less surprising, behavior.
2023-07-10 10:37:42 +02:00
Lewis Buckley 08a79ce284
Add a load hook for `ActiveModel::Model`
ActiveRecord::Base has a dedicated ActiveSupport load hook. This adds an
additional hook for ActiveModel::Model, so that when ActiveModel is
being used without ActiveRecord, it can still be modified.
2023-07-09 13:08:34 +01:00
Mike Dalessio 44d3b44d9d
Add config.action_text.sanitizer_vendor
Rails 7.1 defaults to Rails::HTML::Sanitizer.best_supported_vendor,
earlier configs will use Rails::HTML4::Sanitizer.

Related to #48523 / 55bca6b8.
2023-07-04 08:54:46 -04:00
zzak a234669d63
Disable database prepared statements when query logs are enabled
Fixes #48398

Prepared Statements and Query Logs are incompatible features due to query logs making every query unique.

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2023-07-03 16:59:44 +09:00
Xavier Noria 0568bc9a90 Introduce config.autoload_lib_once(ignore:) 2023-06-29 09:15:17 +02:00
Xavier Noria 90047b52cd Document and test lib & config.add_autoload_paths_to_load_path 2023-06-27 23:50:43 +02:00
Guillermo Iguaran 10b4bd597f
Merge branch 'main' into hm-config-exception-level 2023-06-26 19:07:08 -07:00
Matthew Hirst 00ebbbd746
This allows Rails projects with multiple databases to specify which database they would like the migrations to be copied to. 2023-06-26 19:27:47 +02:00
Hartley McGuire 519577ecc3
Make the log level in DebugExceptions configurable
This middleware has been logging at a FATAL level since the first
[commit][1] in Rails (the code originally lived in
actionpack/lib/action_controller/rescue.rb). However, FATAL is
documented in the Ruby Logger [docs][2] as being for "An unhandleable
error that results in a program crash.", which does not really apply to
this case since DebugExceptions is handling the error. A more
appropriate level would be ERROR, which the Ruby Logger docs describe as
"A handleable error condition."

This commit introduces a new configuration for the DebugExceptions log
level so that new apps will have it set to ERROR by default and ERROR
can eventually be made the default.

[1]: db045dbbf6
[2]: https://ruby-doc.org/3.2.1/stdlibs/logger/Logger/Severity.html
2023-06-25 23:11:39 -04:00
Xavier Noria f27dd78b07 Remove unnecessary Rails module usage 2023-06-25 10:52:53 +02:00
Xavier Noria a35689a533
Merge pull request #48572 from rails/autoload-lib
Introduce config.autoload_lib
2023-06-25 10:43:10 +02:00
Xavier Noria e1321a291f Introduce config.autoload_lib 2023-06-25 10:17:08 +02:00
Jorge Manrubia c8d26bb647
Add a encryption option to support previous data encrypted non-deterministically with a SHA1 hash digest (#48530)
* Make sure active record encryption configuration happens after initializers have run

Co-authored-by: Cadu Ribeiro <mail@cadu.dev>

* Add a new option to support previous data encrypted non-deterministically with a hash digest of SHA1

There is currently a problem with Active Record encryption for users updating from 7.0 to 7.1 Before
#44873, data encrypted with non-deterministic encryption was always using SHA-1. The reason is that
`ActiveSupport::KeyGenerator.hash_digest_class` is set in an after_initialize block in the railtie config,
but encryption config was running before that, so it was effectively using the previous default SHA1. That
means that existing users are using SHA256 for non deterministic encryption, and SHA1 for deterministic
encryption.

This adds a new option `use_sha1_digest_for_non_deterministic_data` that
users can enable to support for SHA1 and SHA256 when decrypting existing data.

* Set a default value of true for `support_sha1_for_non_deterministic_encryption` and proper initializer values.

We want to enable the flag existing versions (< 7.1), and we want it to be false moving by
default moving forward.

* Make sure the system to auto-filter params supports different initialization orders

This reworks the system to auto-filter params so that it works when encrypted
attributes are declared before the encryption configuration logic runs.

Co-authored-by: Cadu Ribeiro <mail@cadu.dev>

---------

Co-authored-by: Cadu Ribeiro <mail@cadu.dev>
2023-06-25 10:16:22 +02:00
Christian Schmidt 11ed5b5c52 Rename Range#overlaps? to Range#overlap?
Rename for consistency with #include? and #cover?
2023-06-23 10:25:59 +02:00
Alex Baldwin e4002fcc40 Document Dev Container CLI setup in guides 2023-06-21 15:53:27 -04:00
zzak 8725f61cdb
Merge pull request #48526 from ghiculescu/active-job-docs
Update Active Job testing guide
2023-06-21 14:38:31 +09:00
Alex 10bb51a123 Update Active Job testing guide
The testing guide for Active Job currently implies that when you queue a job it will be performed.

This isn't true; by default jobs are enqueued, not performed.

This PR fleshes out the docs a bit to show both examples, and adds a test to confirm the default behaviour.
2023-06-20 09:58:33 +10:00
Mike Dalessio cbc79095c2
Update guides generation to use Nokogiri's HTML5 parser
Note that the most frequent change to the output are:

- attribute values, most often data-clipboard-text. libgumbo
  entity-escapes fewer characters in attribute values than libxml2, and
  wraps them in double-quotes. In particulary `>` and `<` are not
  escaped per the HTML5 spec.
- linebreaks are different for some HTML elements, particularly lists.
2023-06-19 15:38:13 -04:00
Petrik de Heus 676fdb1414
Merge pull request #48404 from soartec-lab/task/add-doc-to-activerecord-pick
Added documentation for `ActiveRecord::Relation#pick` [skip ci]
2023-06-19 15:57:03 +02:00
soartec-lab 48a26f5073 Added documentation for `ActiveRecord::Relation#pick` [skip ci]
- Add nuances of the primarily useful cases to the code examples
- Changed description to use some wording from API docs
2023-06-19 17:39:07 +09:00
Petrik 275a6130c1 Set secret_key_base on config in bug_report_templates
`secrets` are deprecated. For the bug templates we can set the
`secret_key_base` on `config` instead.
2023-06-18 18:58:22 +02:00