"title"=>"Enhanced assert_broadcasts, file support for Logger outputs and more!",
"summary"=>"Hope you’re having a lovely weekend. Emmanuel here with yet another batch of Rails updates for you!",
"content"=>"
Hope you’re having a lovely weekend. Emmanuel here with yet another batch of Rails updates for you!
\n\nassert_broadcasts returns the messages that were broadcast\n
\nassert_broadcasts now not only confirms the broadcast but also provides access to the messages that were broadcast. This enhancement, similar to what we have in assert_emails, facilitates additional analyses of the transmitted messages.
\nHere’s an example:
def test_emails_more_thoroughly\n email = assert_emails 1 do\n ContactMailer.welcome.deliver_now\n end\n assert_email 'Hi there', email.subject\n\n emails = assert_emails 2 do\n ContactMailer.welcome.deliver_now\n ContactMailer.welcome.deliver_later\n end\n assert_email 'Hi there', emails.first.subject\nend\n
Autosaving has_one sets foreign key attribute when unchanged
\nThis pull request corrected an issue where the has_one association would erroneously set the foreign key attribute even when unchanged. This behavior was inconsistent with the autosaving mechanism of belongs_to associations and could lead to unintended side effects, such as triggering an ActiveRecord::ReadOnlyAttributeError when the foreign key attribute is set as read-only.
Fix override existing join types in the query in the where.associated method
\nThe fix now ensures that the association is joined using the correct join type (either INNER JOIN or LEFT OUTER JOIN) based on the existing joins in the scope. This prevents inadvertent overrides of existing join types and guarantees consistency in the resulting SQL queries.
Add parameter filter capability for redirect locations
\nHere we add a parameter filter capability for redirect locations. This feature utilizes the config.filter_parameters to determine which parameters should be filtered. As a result, redirects will not display filtered parameters, ensuring sensitive information remains protected. A redirect location with filtered parameters will now look like: Redirected to secret.foo.bar?username=roque&password=[FILTERED].
Support filenames in Logger.logger_outputs_to?
\nWell, this one is straightforward, we can now do stuff like Logger.logger_outputs_to?(‘/var/log/rails.log’).
That’s it! We saw 43 people contribute to Rails this past week!
\n\nTake care :)
\n\nYour weekly inside scoop of interesting commits, pull requests and more from Rails.
\n\nSubscribe to get these updates mailed to you.
","author"=>"Emmanuel Hayford",
"link"=>"https://rubyonrails.org/2024/2/24/this-week-in-rails-enhanced-assert_broadcasts-file-support-for-logger-outputs-and-more-25a0f981",
"published_date"=>Sat, 24 Feb 2024 00:00:00.000000000 UTC +00:00,
"image_url"=>nil,
"feed_url"=>"https://rubyonrails.org/2024/2/24/this-week-in-rails-enhanced-assert_broadcasts-file-support-for-logger-outputs-and-more-25a0f981",
"language"=>nil,
"active"=>true,
"ricc_source"=>"feedjira::v1",
"created_at"=>Wed, 03 Apr 2024 14:31:21.079737000 UTC +00:00,
"updated_at"=>Tue, 14 May 2024 04:41:54.825848000 UTC +00:00,
"newspaper"=>"Ruby on Rails",
"macro_region"=>"Technology"}