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

Make purchase helper pick default storage location #4722

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

lenikadali
Copy link

Resolves #4436

Description

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Screenshots

Changed the purchase helper to use the default storage location
of the organization first, before using any other storage locations
that are available.

Also added a (failing) spec to check that we can see the option
on the page. Should be fixed in the next commit
@lenikadali lenikadali force-pushed the 4436-default-storage-location-for-purchase-donation branch from 8f44b71 to bf3a652 Compare October 14, 2024 19:15
Fixed the failing test by using the extended format
of the test expectation and used `subject` to make
an assertion regarding the response body.
@lenikadali
Copy link
Author

The next step here is to apply the default storage location (if set) to donations.

I see that the donations form was implemented differently from the purchases form in that we directly set the location in the form as shown here while the purchases form uses a helper function as shown here.

The open question: should we switch the donation form to use a (new) method declared in app/helpers/donations_helper.rb or directly check that the organization has a default storage location in the form?

@dorner
Copy link
Collaborator

dorner commented Oct 22, 2024

Wouldn't switching the donation form to use the same helper as purchases do what we need here?

@cielf
Copy link
Collaborator

cielf commented Oct 22, 2024

I don't know of any functional reason they shouldn't behave exactly the same, fwiw.

Added a test that when we begin to make a new donation,
we have a default storage location set.
Switched to use the helper method from PurchasesHelper
to set the default storage location for a donation
@lenikadali
Copy link
Author

Wouldn't switching the donation form to use the same helper as purchases do what we need here?

I think so. Why I would be hestitant to use it is separation of concerns etc.

Also something strange: in commit 231b516, I added a test to check that the default storage location was being used by checking the content of the form. The test passed 🤔 which made me think that there may be something I am missing regarding the behaviour of the new donation form versus the new purchases form.

Anyway in the subsequent commit e048651, I updated the form to use the method from the PurchasesHelper module and the test still passes.

This should be good for another review 🙏🏿

@cielf
Copy link
Collaborator

cielf commented Oct 23, 2024

Hey @lenikadali -- when a PR is ready for review, please change its status to "Open".

@lenikadali lenikadali marked this pull request as ready for review October 23, 2024 18:45
@cielf cielf self-requested a review November 7, 2024 14:19
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

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

LGTM from a functional POV

Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

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

Minor suggestion, otherwise looks good.

@@ -39,7 +39,7 @@
<div class="col-xs-8 col-md-6 col-lg-3">
<%= f.association :product_drive_participant,
collection: @product_drive_participants,
selected: donation_form.product_drive_participant_id,
selected: new_purchase_default_location(@donation),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we rename this method so it doesn't have purchase in its name? You can move it to ApplicationHelper.

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.

Storage Location on purchase and donation should default to the Default Intake Location
3 participants