Commit Graph

89118 Commits

Author SHA1 Message Date
Petrik
989de534a5 Add tests for send_file and redirect_to instrumentation 2023-09-30 17:22:56 +02:00
Jean Boussier
0d0e6bd5df
Merge pull request #49378 from Shopify/ar-delay-version-check
Delay Adapter#check_version to #configure_connection
2023-09-29 09:21:38 +02:00
Jean Boussier
2da1852ac9 Delay Adapter#check_version to #configure_connection
Ideally we should be able to checkout an Adapter instance without
triggering a connection to the server.

For some adapters like Trilogy that is the case today, but only if
you have a schema cache loaded, otherwise `check_version` will trigger
a query.

I think this check can be delayed to when we actually use the connection.
2023-09-29 08:53:16 +02:00
Hartley McGuire
0b2fb5d29f
Merge pull request #49427 from koic/tweak_async_api_docs
Tweak the docs for `async_*` APIs [ci skip]
2023-09-28 22:26:24 -04:00
Koichi ITO
0bdf160f3a Tweak the docs for async_* APIs [ci skip]
This PR adds period at the end of sentences to maintain consistency in the `async_*` API document.
2023-09-29 11:19:21 +09:00
Rafael Mendonça França
deb0869f3b
Merge pull request #49426 from skipkayhil/hm-rm-default-forgery-accessor
Rm unused default_protect_from_forgery accessor
2023-09-28 21:32:23 -04:00
Hartley McGuire
3946ef20e1
Rm unused default_protect_from_forgery accessor
This was [added][1] when the default configuration was added for Rails
5.2, however the accessor itself has never been documented or used.
`protect_from_forgery: :exception` is added based on  whether the
configuration is set on `config.action_controller` and not this value.

Since the accessor is undocumented and unused, this commit removes it.

[1]: 48cb8b3e7097e9a1cb45b2298f59b9179f0dbdee
2023-09-28 20:38:44 -04:00
Hartley McGuire
b4d8603bd3
Merge pull request #49418 from akhilgkrishnan/html-to-erb
Fix the wrong markdown highlighting [skip ci]
2023-09-28 13:26:44 -04:00
Rafael Mendonça França
af95a7d89f
Merge pull request #49416 from Shopify/fix-render-call-extractor-on-ruby-3.3
Fix RenderCallExtractor to be compatible with Ruby 3.3
2023-09-28 11:57:23 -04:00
Rafael Mendonça França
02313b836e
Merge pull request #49412 from fatkodima/fix-multiple-dbs-example
Enable raising when running `rubocop-md` against invalid ruby snippets
2023-09-28 11:54:39 -04:00
Jean Boussier
ef21ab6a88
Merge pull request #49415 from Shopify/schema-cache-server-version
Move the database version cache from schema cache to pool config
2023-09-28 17:17:16 +02:00
Akhil G Krishnan
2e35046f61 Fix the wrong markdown hightlighting [skip ci] 2023-09-28 20:14:35 +05:30
Eileen M. Uchitelle
9cb6f443d4
Merge pull request #49409 from stevepolitodesign/sp-datetime-local-scaffold
Ensure system test scaffold supports `datetime` and `time` attributes
2023-09-28 09:34:53 -04:00
Jean Boussier
a1c0173ee3 Move the database version cache from schema cache to pool config
Ref: https://github.com/rails/rails/pull/49378

As discussed with Matthew Draper, we have a bit of a chicken and egg
problem with the schema cache and the database version.

The database version is stored in the cache to avoid a query,
but the schema cache need to query the schema version in the database
to be revalidated.

So `check_version` depends on `schema_cache`, which depends on
`Migrator.current_version`, which depends on `configure_connection`
which depends on `check_version`.

But ultimately, we think storing the server version in the cache
is incorrect, because upgrading a DB server is orthogonal from
regenerating the schema cache.

So not persisting the version in cache is better. Instead we store
it in the pool config, so that we only check it once per process
and per database.
2023-09-28 15:18:38 +02:00
Jean Boussier
dfd086edf3 Fix RenderCallExtractor to be compatible with Ruby 3.3
Fix: https://github.com/rails/rails/issues/49128
Ref: https://github.com/ruby/ruby/commit/45cd011d73

We need to unwrap some nodes.
2023-09-28 14:35:01 +02:00
Petrik de Heus
6c9967f85a
Merge pull request #49413 from ghiculescu/document-retry-on
Document hierarchy for `retry_on` and `discard_on`
2023-09-28 07:34:06 +02:00
Petrik de Heus
a7041d3138
Merge pull request #49394 from johanstenberg92/fix-method-documentation-for-attempts-retry-on [ci skip]
Adjust method documentation for `ActiveJob::Exceptions::ClassMethods#retry_on`
2023-09-28 07:28:35 +02:00
Alex
bb8d6c9349 Document hierarchy for retry_on and discard_on
Fixes https://github.com/rails/rails/issues/49406
2023-09-28 15:00:29 +10:00
fatkodima
a7ee313d91 Enable raising when running rubocop-md against invalid ruby snippets 2023-09-27 23:12:48 +03:00
Rafael Mendonça França
7c03e4f1b7
Merge pull request #49175 from akhilgkrishnan/content_tag-html-tag-validation
HTML tag validation added for tag names
2023-09-27 13:37:41 -04:00
Rafael Mendonça França
3c6e7391d8
Merge pull request #49411 from Shopify/call-id-instead-of-sending-key-to-the-record
Use `id` in favor of `send(primary_key)`
2023-09-27 13:32:57 -04:00
Nikita Vasilevsky
1f51409215
Use id in favor of send(primary_key)
There is no reason to send `primary_key` to the record to get the value
of the primary key. `id` method does exactly that and it's a better
abstraction. By implication it also fixes the problem with composite
primary keys.
2023-09-27 16:43:54 +00:00
Rafael Mendonça França
d2a6fd9744
Merge pull request #49410 from koic/add_async_ids_to_7_1_release_notes
Add `async_ids` to 7_1_release_notes [ci skip]
2023-09-27 11:32:44 -04:00
Rafael Mendonça França
32eba97a08
Make sure scheduled_at is a Time object when asserting enqueued jobs
When the `:at` attribute is sent to the test adapter it is converted
to a float, and that float is what is added to the payload, so we
need to convert back to a Time object.

See:
8a37276416/activejob/lib/active_job/enqueuing.rb (L95)
8a37276416/activejob/lib/active_job/queue_adapters/test_adapter.rb (L34)
2023-09-27 15:29:11 +00:00
Steve Polito
d0d1a1b573 Ensure system test scaffold supports datetime and time
Prior to this commit, system tests generated by a scaffold containing
`time` or `datetime` attributes would fail during the update test. The
captured screenshot would reveal the following client-side validation
errors.

```
Please enter a valid value. The two nearest valid values are 10:45:33 AM
and 10:46:33 AM.
```

```
Please enter a valid value. The two nearest valid values are 09/27/2023,
10:45:33 AM and 09/27/2023, 10:46:33 AM.
```

Converting the values to a string ensures they are entered correctly and
that the tests pass.
2023-09-27 11:15:59 -04:00
Rafael Mendonça França
5d48062099
Merge pull request #49403 from fractaledmind/fix-49373
Fix the problem of database connections leaking between tests
2023-09-27 10:58:44 -04:00
Koichi ITO
3e14e8dd62 Add async_ids to 7_1_release_notes [ci skip]
This PR adds `async_ids` introduced at https://github.com/rails/rails/pull/46503
to 7_1_release_notes.
2023-09-27 23:32:44 +09:00
Eileen M. Uchitelle
8d5d0a1303
Merge pull request #49407 from Shopify/do-not-use-backticks-in-docs
[ci skip] do not use backticks in docs
2023-09-27 09:34:21 -04:00
Nikita Vasilevsky
92a8513995
[ci skip] do not use backticks in docs 2023-09-27 13:22:13 +00:00
Akhil G Krishnan
bb626ffca8 HTML tag validation added for tags
Added validation for HTML tag names in the `tag` and `content_tag` helper method. The `tag` and
`content_tag` method now checks that the provided tag name adheres to the HTML specification. If
an invalid HTML tag name is provided, the method raises an `ArgumentError` with an appropriate error
message.

Examples:

```ruby
content_tag("12p") # Starting with a number

content_tag("") # Empty tag name

tag("div/") # Contains a solidus

tag("image file") # Contains a space
```
2023-09-27 18:11:01 +05:30
Ryuta Kamizono
01743ddf8b
Merge pull request #49404 from fatkodima/enable-redundant_safe_navigation
Enable `Lint/RedundantSafeNavigation` rubocop cop
2023-09-27 21:23:07 +09:00
fatkodima
7ef86b6a49 Enable Lint/RedundantSafeNavigation rubocop cop 2023-09-27 14:55:07 +03:00
Stephen Margheim
7dd068c949 Fix the problem of database connections leaking between tests 2023-09-27 11:56:00 +02:00
Johan Stenberg
9ea1e7aa78
Update activejob/lib/active_job/exceptions.rb
Co-authored-by: Alex Ghiculescu <alex@tanda.co>
2023-09-27 08:37:12 +02:00
Rafael Mendonça França
fb6c6007d0
Development of Rails 7.2 starts now
🎉
2023-09-27 03:59:11 +00:00
Rafael Mendonça França
e57a936879
Merge pull request #49397 from hatsu38/fix_typo-author_name-in_md
[skip ci] Docs: Fix typo in author name Paul Coelho -> Paulo Coelho
2023-09-26 23:23:26 -04:00
Rafael Mendonça França
4bd5d20a92
Don't add CHANGELOG offenses to "no changes" line 2023-09-27 03:20:06 +00:00
Rafael Mendonça França
e5386cb402
Preparing for 7.1.0.rc1 release 2023-09-27 03:08:31 +00:00
hatsu38
c0d8528b24 [skip ci] Docs: Fix typo in author name Paul Coelho -> Paulo Coelho 2023-09-27 12:00:55 +09:00
Rafael Mendonça França
d6d47fb027
Merge pull request #49083 from 1st8/actionmailer-log-subscriber-log-errors
Log delivery errors in ActionMailer::LogSubscriber
2023-09-26 22:57:33 -04:00
Rafael Mendonça França
54f30488e1
Also rescue TZInfo::ZoneinfoDirectoryNotFound when loading time zone data
Fixes #49375.
2023-09-27 02:52:20 +00:00
Rafael Mendonça França
e7009b14b6
Remove unused mailer 2023-09-27 02:45:56 +00:00
Christoph Geschwind
647e39b278
Log delivery errors in ActionMailer::LogSubscriber
In case of mail delivery errors, the old ActionMailer::LogSubscriber
erroneously logged a "Delivered mail ..." line.
With this change it checks the passed exception object and logs a
"Failed delivery of mail" line instead.

Co-authored-by: Christian Esser <c_esser@yahoo.de>
2023-09-27 02:45:55 +00:00
Rafael Mendonça França
7893e0a165
Merge pull request #49194 from seanpdoyle/action-view-test-case-encoder
Introduce `ActionView::TestCase.register_parser`
2023-09-26 22:30:25 -04:00
Sean Doyle
7badc42723
Introduce ActionView::TestCase.register_parser
Register a callable to decode rendered content for a given MIME type

Each registered decoder will also define a `#rendered.$MIME` helper
method, where `$MIME` corresponds to the value of the `mime` argument.

=== Arguments

`mime` - Symbol the MIME Type name for the rendered content
`callable` - Callable to decode the String. Accepts the String
                    value as its only argument
`block` - Block serves as the decoder when the
                 `callable` is omitted

By default, ActionView::TestCase defines a decoder for:

* :html - returns an instance of Nokogiri::XML::Node
* :json - returns an instance of ActiveSupport::HashWithIndifferentAccess

Each pre-registered decoder also defines a corresponding helper:

* :html - defines `rendered.html`
* :json - defines `rendered.json`

=== Examples

To parse the rendered content into RSS, register a call to `RSS::Parser.parse`:

```ruby
register_decoder :rss, -> rendered { RSS::Parser.parse(rendered) }

test "renders RSS" do
  article = Article.create!(title: "Hello, world")

  render formats: :rss, partial: article

  assert_equal "Hello, world", rendered.rss.items.last.title
end
```

To parse the rendered content into a Capybara::Simple::Node,
re-register an `:html` decoder with a call to
`Capybara.string`:

```ruby
register_decoder :html, -> rendered { Capybara.string(rendered) }

test "renders HTML" do
  article = Article.create!(title: "Hello, world")

  render partial: article

  rendered.html.assert_css "h1", text: "Hello, world"
end
```
2023-09-27 02:03:23 +00:00
Rafael Mendonça França
d87ecd0467
Merge pull request #49396 from jonfoster9999/fix-typo-in-new_framework_defaults_7_1
fix typo in new_framework_defaults_7_1.rb.tt
2023-09-26 21:24:49 -04:00
Jonathan Foster
b729d7efda fix typo in new_framework_defaults_7_1.rb.tt 2023-09-26 20:31:11 -04:00
Rafael Mendonça França
bdbc1825c0
Merge pull request #48066 from bensheldon/aj_scheduled_at
Set, serialize, and deserialize Active Job `scheduled_at` as Time; deserialize `enqueued_at` as Time; deprecate setting `scheduled_at=` with numeric/epoch
2023-09-26 20:30:14 -04:00
Ben Sheldon [he/him]
c919b474a7
Set, serialize, and deserialize Active Job scheduled_at as Time; deserialize enqueued_at as Time; deprecate setting scheduled_at= with numeric/epoch
Co-authored-by: Adam Pahlevi <adam.pahlevi@gmail.com>
2023-09-26 17:01:41 -07:00
Rafael Mendonça França
60002c3af6
Fix some more quotes 2023-09-26 21:59:18 +00:00