-
-
Notifications
You must be signed in to change notification settings - Fork 572
5428 Sort vendor purchases by issued_at in reverse chronological order #5429
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
5428 Sort vendor purchases by issued_at in reverse chronological order #5429
Conversation
…tead of the model, fix up automated tests
c7bef63 to
723519a
Compare
app/views/vendors/show.html.erb
Outdated
| </thead> | ||
| <tbody> | ||
| <% @vendor.purchases.each do |purchase| %> | ||
| <% @vendor.purchases.order(issued_at: :desc).each do |purchase| %> |
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 prefer not doing anything but a very straight association call in the view - I'd rather add @purchases to the controller code and reference it here.
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.
That makes sense. I removed the logic from the view and added to the vendors controller.
|
|
||
| get vendor_path(vendor) | ||
|
|
||
| expect(vendor.reload.purchases.order(issued_at: :desc).to_a).to eq([new_purchase, middle_purchase, old_purchase]) |
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.
This isn't actually testing the view - you're just testing the database here. You need to inspect the response (i.e. response.body) to see that it contains the purchase dates in the expected order.
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.
Got it. Adjusted the test, please check it out and let me know if it's better. Thanks!
… view through the response.body
dorner
left a comment
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! Over to @awwaiid for functional test.
|
Functionally tested ALSO |
|
@janeewheatley: Your PR |
Resolves #5428
Description
We fixed the list of purchases in the vendor view to be in reverse chronological order by entered date (which is the issued_at date instead of the created_at) of purchased goods. The issued_at date is the date when the goods were actually purchased on the store receipt (which is entered manually by a user) vs. just when the event was created (possibly weeks later).
Type of change
How Has This Been Tested?
I tested this code locally and saw that the purchase dates are now being ordered correctly. I have also created an automated test that appears to be passing.
Screenshots
Before:

After:
