-
-
Notifications
You must be signed in to change notification settings - Fork 498
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
base: main
Are you sure you want to change the base?
Make purchase helper pick default storage location #4722
Conversation
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
8f44b71
to
bf3a652
Compare
Fixed the failing test by using the extended format of the test expectation and used `subject` to make an assertion regarding the response body.
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 |
Wouldn't switching the donation form to use the same helper as purchases do what we need here? |
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
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 This should be good for another review 🙏🏿 |
Hey @lenikadali -- when a PR is ready for review, please change its status to "Open". |
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 from a functional POV
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.
Minor suggestion, otherwise looks good.
Addressed review feedback namely: * Renaming new_purchase_default_location to set_default_location and moving it to ApplicationHelper. This allows us to use across both the donation and purchase forms. * Updated the tests and forms accordingly * Added specs to ApplicationHelper to test that we are able to successfully set the default storage location for purchases and donations.
Hi @dorner Thanks a lot for the review 🙌 I think you can give it another look and it should be good 🤞 |
end | ||
end | ||
|
||
describe "#set_default_location for donation" do |
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.
I don't think we need to copy the same test for all things that have storage locations - all we're doing is referencing the storage_location_id
of that thing.
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.
I've opted to keep one test as per commit 2716706 so that we guarantee the functionality of the method and any subsequent changes to it.
Let me know if that is in keeping with what you were suggesting or your proposal was to remove the test altogether.
Renamed the method as per review suggestion and keep only one test since we only need to test that the default storage location is successfully set
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.
Looks good!
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.
oof... @lenikadali tests are failing now. :(
Should be green in the next run @dorner It seems I forgot to update the other usages of |
Found that I hadn't update the view code to use the new method; hopefully the pipeline passes now 🤞 |
Took a look at the last failing spec and I am not sure how to fix it. Currently if you make the following changes to the
The spec will pass. Probably because we've changed the form's behaviour:
Should I update the spec? (I am not sure how or what the desired behaviour in this case would be) |
@lenikadali yes, let's update the spec so it matches the new behavior. |
Updated spec to match the new behaviour of the donation form.
Updated the spec. The pipeline should be green now 🤞 |
Resolves #4436
Description
Type of change
How Has This Been Tested?
Screenshots