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

Rename methods to be more informative, fix bug with double rendering … #1512

Merged
merged 2 commits into from
Mar 2, 2020

Conversation

murny
Copy link
Contributor

@murny murny commented Mar 2, 2020

…page image url

Noticed this bug when working on webpacker. It works fine on an item/community, but broken on the default image url. Here is what this page_image helper out puts for default image url in production currently:

image

Notice the root url and image url being appended together which is not a valid url.

Part of the problem i think is the confusion between url and path. So cleaned up those model methods to be more informative.

@@ -46,7 +46,7 @@ def thumbnail
end

# compatibility with the thumbnail API used in Items/Theses and Communities
def thumbnail_url(args = { resize: '100x100', auto_orient: true })
def thumbnail_path(args = { resize: '100x100', auto_orient: true })
return nil unless thumbnail.present? && thumbnail.blob.present?

Rails.application.routes.url_helpers.rails_representation_path(thumbnail.variant(args).processed)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As you notice here we are returning the rails_representation_path instead of the rails_representation_url in this thumbnail_url helpers. Lets rename these to thumbnail_path as this is what its actually returning

@@ -26,15 +26,15 @@
<meta property="og:locale" content="en_US">
<meta property="og:title" content="<%= page_title %>">
<meta property="og:description" content="<%= page_description %>">
<meta property="og:image" content="<%= request.base_url + page_image %>">
<meta property="og:image" content="<%= page_image_url %>">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move this request.base_url concatenation into the helper itself. This was causing the bug on the default images. Update the helper name to be more informative (page_image vs page_image_url)

@@ -2,6 +2,16 @@

class PageLayoutHelperTest < ActionView::TestCase

attr_reader :request
Copy link
Contributor Author

@murny murny Mar 2, 2020

Choose a reason for hiding this comment

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

We don't have access to request inside test helpers. Some setup to fake this

Copy link
Contributor

@mbarnett mbarnett left a comment

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor

@ConnorSheremeta ConnorSheremeta left a comment

Choose a reason for hiding this comment

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

LGTM!

@murny murny merged commit 2877fcb into integration_postmigration Mar 2, 2020
@murny murny deleted the fix-page-image-helper branch March 2, 2020 19:37
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