Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace #to_s(:format) with #to_fs #17219

Merged
merged 1 commit into from
Apr 11, 2022

Conversation

tnir
Copy link
Contributor

@tnir tnir commented Apr 11, 2022

Signed-off-by: Takuya Noguchi takninnovationresearch@gmail.com

What type of PR is this? (check all applicable)

  • Refactor

Description

Replaces TimeWithZone#to_s(:format) with TimeWithZone#to_fs.

Related Tickets & Documents

Rails 7 deprecated TimeWithZone#to_s(:format) in favor of TimeWithZone#to_fs.

DEPRECATION WARNING: TimeWithZone#to_s(:rfc822) is deprecated. Please use TimeWithZone#to_fs(:rfc822) instead. (called from block (4 levels) in _app_views_articles_feed_rss_builder__990977305614084656_3900980 at /home/travis/build/forem/forem/app/views/articles/feed.rss.builder:44)

from https://app.travis-ci.com/github/forem/forem/jobs/566636747

Added/updated tests?

  • No, and this is why: no logic changed.

[optional] Are there any post deployment tasks we need to perform?

No.

rails/rails#43772
rails/rails#44354

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
@tnir tnir requested a review from a team April 11, 2022 16:13
@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Apr 11, 2022
@github-actions
Copy link
Contributor

Thank you for opening this PR! We appreciate you!

For all pull requests coming from third-party forks we will need to
review the PR before we can process it through our CI pipelines.

A Forem Team member will review this contribution and get back to
you as soon as possible!

@@ -41,7 +41,7 @@ xml.rss(:version => "2.0",
xml.item do
xml.title article.title
xml.tag!("dc:creator", user.instance_of?(User) ? user.name : article.user.name)
xml.pubDate article.published_at.to_s(:rfc822) if article.published_at
xml.pubDate article.published_at.to_fs(:rfc822) if article.published_at
Copy link
Contributor

@djuber djuber Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks exactly like the suggested fix in the deprecation. Thanks!

The xml response being built is used for rss feeds (see https://dev.to/feed for examle), and I don't see any tests around this endpoint (I might not have looked closely enough, but it wasn't in the places I would have expected to find them). We probably want to add a test to confirm whether this is making any changes in behavior.

A minimal spec/requests/articles/articles_feed_spec.rb file covering the response content (not parsing the xml or validating that the rss is readable, only asserting the article is in the feed and the date is formatted the way we expect):

require "rails_helper"

RSpec.describe "ArticlesFeed", type: :request do
  let!(:article) { create(:article) }

  it "returns an rss feed with published article details" do
    get "/feed"

    expect(response.body).to include(article.title)
    expect(response.body).to include("<pubDate>#{article.published_at.to_fs(:rfc822)}</pubDate>")
  end
end

I checked with expecting both of these values in the response body, it showed no difference for me and passed both times (the first does give a deprecation warning)

"<pubDate>#{article.published_at.to_s(:rfc822)}</pubDate>"
"<pubDate>#{article.published_at.to_fs(:rfc822)}</pubDate>"

@pr-triage pr-triage bot added PR: partially-approved bot applied label for PR's where a single reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Apr 11, 2022
@pr-triage pr-triage bot added PR: reviewed-approved bot applied label for PR's where reviewer approves changes and removed PR: partially-approved bot applied label for PR's where a single reviewer approves changes labels Apr 11, 2022
@jeremyf jeremyf merged commit 3edffcb into forem:main Apr 11, 2022
@pr-triage pr-triage bot added PR: merged bot applied label for PR's that are merged and removed PR: reviewed-approved bot applied label for PR's where reviewer approves changes labels Apr 11, 2022
@tnir tnir deleted the tnir/to_s_format_deprecation branch April 18, 2022 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged bot applied label for PR's that are merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants