-
-
Notifications
You must be signed in to change notification settings - Fork 503
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 row for grand totals to storage locations index view #4768
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,23 @@ | |
end | ||
end | ||
|
||
it "displays the correct grand totals across all storage locations" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a request spec, not a system spec since there's no interaction. Request specs are a lot faster and more lightweight. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this still needed now that we have the request spec? |
||
item = create(:item, name: "Needle", value_in_cents: 100) | ||
|
||
location1 = create(:storage_location, name: "Location 1") | ||
create(:donation, :with_items, item: item, item_quantity: 30, storage_location: location1) | ||
|
||
location2 = create(:storage_location, name: "Location 2") | ||
create(:donation, :with_items, item: item, item_quantity: 70, storage_location: location2) | ||
|
||
visit subject | ||
|
||
within "tbody tr:last-child" do | ||
expect(page).to have_content(100) # The expected total inventory | ||
expect(page).to have_content("$100.00") # The expected total fair market value | ||
end | ||
Comment on lines
+106
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a better way to test the totals show up as expected without writing a system test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes! You can look at some other request tests to see how it parses the rendered body and checks for elements. |
||
end | ||
|
||
it "User can filter the #index by those that contain certain items" do | ||
item = create(:item, name: Faker::Lorem.unique.word) | ||
create(:item, name: Faker::Lorem.unique.word) | ||
|
@@ -103,15 +120,15 @@ | |
select item.name, from: "filters[containing]" | ||
click_button "Filter" | ||
|
||
expect(page).to have_css("table tr", count: 2) | ||
expect(page).to have_css("table tr", count: 3) | ||
expect(page).to have_xpath("//table/tbody/tr/td", text: location1.name) | ||
expect(page).not_to have_xpath("//table/tbody/tr/td", text: location2.name) | ||
expect(page).not_to have_xpath("//table/tbody/tr/td", text: location3.name) | ||
|
||
check "include_inactive_storage_locations" | ||
click_button "Filter" | ||
|
||
expect(page).to have_css("table tr", count: 3) | ||
expect(page).to have_css("table tr", count: 4) | ||
expect(page).to have_xpath("//table/tbody/tr/td", text: location3.name) | ||
end | ||
|
||
|
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.
You should pass
@inventory
to that method so it isn't recalculating it each time.