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

Add #gallery to Spree::Variant and Spree::Product #2323

Closed
wants to merge 4 commits into from
Closed

Add #gallery to Spree::Variant and Spree::Product #2323

wants to merge 4 commits into from

Conversation

swcraig
Copy link
Contributor

@swcraig swcraig commented Oct 24, 2017

This is a lightweight version of #625.

Related to #2324, I think this is a good starting point to begin opening up an interface for different image upload implementations.

This wraps the `has_many :images` association of Variants. If we decide
to change the implementation  of images on variants (or get rid of them
completely) this will keep the API from breaking.
This wraps the collection of images that a product gets from its
variants. If we decide to change the implementation of images on
products (or remove them completely) this will keep the API from
breaking.
Uses `Product#gallery`. The thumbnails for products no longer include
the master variant's images. Showing a thumbnail for the master variant
doesn't make sense since that variant isn't something that a user can
elect to buy.
Copy link

@houndci-bot houndci-bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

.rubocop.yml: Style/FileName has the wrong namespace - should be Naming
.rubocop.yml: Style/FileName has the wrong namespace - should be Naming
.rubocop.yml: Style/PredicateName has the wrong namespace - should be Naming
.rubocop.yml: Style/AccessorMethodName has the wrong namespace - should be Naming
.rubocop.yml: Style/VariableNumber has the wrong namespace - should be Naming
Error: The `Style/OpMethod` cop has been renamed and moved to `Naming/BinaryOperatorParameterName`.
(obsolete configuration found in .rubocop.yml, please update it)

@@ -1,19 +1,10 @@
<%# no need for thumbnails unless there is more than one image %>
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't change the behaviour of this file. We can't have it so users upgrade and the logic for displaying images on the frontend changes (I think it's likely in a ton of stores that this wouldn't be caught before production).

#
# @return [Enumerable] of media for a variant
def gallery
Variant.reflect_on_association(:images) ? association(:images).reader : []
Copy link
Contributor

Choose a reason for hiding this comment

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

We define this association, so we shouldn't test for it. If this is to prepare for a future paperclip removal PR, it should be done later.

#
# @return [Enumerable] of media for a product (and its variants)
def gallery
if Product.method_defined?(:variant_images)
Copy link
Contributor

Choose a reason for hiding this comment

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

We define this association, so we shouldn't test for it. If this is to prepare for a future paperclip removal PR, it should be done later.

@jordan-brough jordan-brough mentioned this pull request Oct 24, 2017
@swcraig
Copy link
Contributor Author

swcraig commented Oct 30, 2017

Closed in favour of #2337

@swcraig swcraig closed this Oct 30, 2017
@swcraig swcraig deleted the add-gallery-to-variants-and-products branch October 30, 2017 23:20
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