8000 Fix support for adding social image to the Pages API by PhilipHow · Pull Request #20916 · forem/forem · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix support for adding social image to the Pages API #20916

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

Merged
merged 3 commits into from
May 6, 2024

Conversation

PhilipHow
Copy link
Contributor
@PhilipHow PhilipHow commented May 2, 2024

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

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

This fixes support for specifying the social_image for Pages via the API. The docs don't specify a format for the URL, I've used the same format as the GET route ... social_image: { url: "https://blah.png" }.

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above.

  • Yes: I was shamed into doing it.
  • No, and this is why:
  • I need help with writing tests

@PhilipHow PhilipHow marked this pull request as ready for review May 2, 2024 18:57
@PhilipHow PhilipHow requested a review from a team as a code owner May 2, 2024 18:57
@PhilipHow PhilipHow requested review from lightalloy and maestromac and removed request for a team May 2, 2024 18:57
@PhilipHow PhilipHow marked this pull request as draft May 2, 2024 18:57
Copy link
Contributor
github-actions bot commented May 2, 2024

Uffizzi Ephemeral Environment Deploying

☁️ https://app.uffizzi.com/github.com/forem/forem/pull/20916

⚙️ Updating now by workflow run 8937638497.

What is Uffizzi? Learn more!

@PhilipHow PhilipHow marked this pull request as ready for review May 2, 2024 19:16
@PhilipHow PhilipHow requested review from benhalpern and removed request for lightalloy May 2, 2024 19:16
@PhilipHow PhilipHow requested a review from maestromac May 3, 2024 09:11
Copy link
Contributor
@maestromac maestromac left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -39,8 +39,11 @@ def require_admin
end

def permitted_params
if params[:social_image].present? && params[:social_image][:url].present?
Copy link
8000
Contributor

Choose a reason for hiding this comment

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

non-blocking nit: there's a nice dig method for this.

Suggested change
if params[:social_image].present? && params[:social_image][:url].present?
if params.dig(:social_image, :url).present?

Copy link
Contributor
@benhalpern benhalpern left a comment

Choose a reason for hiding this comment

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

Looks good.

I have some confusion on whether simply setting a param of remote_social_image_url works vs having to call the method as a setter, but I think the tests seem to show this works.

And if there's still a small additional change to be made we can do as a follow-up.

@benhalpern benhalpern merged commit 37c2fb1 into main May 6, 2024
@benhalpern benhalpern deleted the phil/fix-pages-api branch May 6, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0