-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
@@ -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) |
There was a problem hiding this comment.
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 %>"> |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…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:
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
andpath
. So cleaned up those model methods to be more informative.