Skip to content

(EPIC) Expand test coverage #1024

@armahillo

Description

@armahillo

Attention Conference Contributors

This is a great issue to get some PRs in! Take a look at coverage/index.html (you might want to re-run it to be sure yours is current!) and identify some areas of the app that have missing coverage.

If you don't have coverage/index.html, you can generate it by running the full rspec suite (bundle exec rspec). This will take a little bit, 10-20 mins depending on your computer.

Write some tests, re-run the suite and get that to change. Submit a PR with your test example(s) and you're good!

There are a lot of basic tests that need to be written to up our code coverage (we have a lot of tests already, but the app's been growing a lot this past year), so this should be an easy submission. Thank you!

Summary

We've had a few bugs leak into the codebase over the past 6 months. Many of them should have been caught by specs but it looks like we're missing some specs for some basic functionality.

Your mission, should you choose to contribute, is to submit pull-requests that expand test coverage for our various resources. We don't need every edge-case; many of them just need normal work-flows covered by test. I'll try to maintain a list of specs to be added here, as a checklist.

Contributing

Grab one, submit a PR and tag this issue with a Ref (but not Closes or Fixes) such as:

Ref #1024
Put as many specs as you like in each PR, but don't submit WIP PRs for this -- just churn'n'burn.

Criteria for Contribution

Each PR should:

  • Expand the spec coverage by either adding a new example(s) or correcting existing ones that were incomplete
  • Pass CI

Burndown List

Reference SimpleCov -- let's get that covered for starters. If you notice anything missing in the feature specs, please add that and Ref tag this issue. 🙇‍♂️

Controllers

BarcodeItemsController (98%)

  • #font is untested (uses send_file)

Admin/OrganizationsController (98%)

  • #destroy Verify failure path

DistributionsController (97%)

  • #destroy Verify failure path
  • #pick_ups is untested
  • #picked_up Verify failure path

API/PartnerRequestsController

  • #create: Verify failure path

API/FamilyRequestsController

  • #create: Verify failure path

DashboardController (93%)

  • #index: Verify that it succeeds with :itemized_distributions flipped on

StaticController (92%)

  • #page is untested

Admin/BarcodeItemsController (92%)

  • #destroy: Verify failure path
  • #filter_params: Verify filtering works

Admin/UsersController (91%)

  • #update: Verify failure path
  • #destroy: Verify failure path

ApplicationController (91%)

  • #organization_url_options is untested
  • #default_url_options: one path is untested ("current_user, not a super admin, signed into an organization)
  • #omgwtfbbq! (500!) is untested

DonationsController (90%)

  • #scale is untested (is this used anymore?)
  • #scale_intake is untested (is this used anymore?)
  • #update: Verify failure path
  • #donation_item_params is untested
  • #compact_line_items is untested past guard clause

PurchasesController (90%)

  • #update Verify failure path
  • #compact_line_items is untested past guard clause
  • #total_value is untested

OrganizationsController (89%)

  • #resend_user_invitation is untested

AuditsController (89%)

  • #finalize "if line_item.nil?" branch is untested
  • #update Verify failure path
  • #create Verify rescue path

Admin/BaseItemsController (86%)

  • #destroy is untested

StorageLocationsController (86%)

  • #import_inventory is untested

DiaperDrivesController (83%)

  • #create Verify failure path
  • #update Verify failure path
  • #date_range_filter is untested
  • #filter_params is untested after guard clause

PartnersController (65%)

  • #approve_application is untested
  • #approve_partner is untested
  • #re_invite is untested
  • #recertify_partner is untested
  • #autovivifying_hash is untested (and probably belongs in AppCo)

Models

Itemizable (98%) (N.B. this will be covered by itemizable_shared_example)

  • #quantities_by_category is untested

Purchase (98%)

  • #replace_increase! Verify rescue block

Organization (96%)

  • #display_users is untested
  • #address_inline is untested (and should maybe be moved to a helper?)
  • #scale_values is untested (and is maybe unnecessary)

Partner (96%)

  • #add_user_on_partnerbase is untested

Item (96%)

  • .gather_items Verify branch when global is true
  • #to_h is untested

Donation (93%)

  • #format_drive_name is untested for diaper drives & else branches
  • #daily_quantities_by_source is untested
  • #replace_increase! Verify rescue branch

StorageLocation (93%)

  • #to_csv is untested

Manufacturer (92%)

  • #exists_in_org? is untested

Errors (84%)

  • #add_insufficiency is untested
  • #satisfied? is untested

Helpers

ApplicationHelper (97%)

  • #navigation_link_to is untested

UiHelper (94%)

  • #dropdown_button is untested

DashboardHelper (89%)

  • #total_received_from_diaper_drives is untested
  • #total_purchased is untested
  • #total_received_from_diaper_drives_unformatted is untested

DistributionHelper (87%)

  • #pickup_day_params is untested past guard clause

DateRangeHelper (76%) - this might be artificially low because we're currently skipping a lot of these tests

  • #date_range_params is untested on all when branches
  • #selected_range_described is untested when "today"

Jobs

ApplicationJob (0%)

  • This is because all other jobs need to inherit from it

AddDiaperPartnerJob (0%)

  • #perform is untested (this should get the file to 💯)

Libraries

DistributionMailerPreview (0%)

  • #partner_mailer is untested

Moving Local Storage Files (0%)

  • ActiveStorageBlob is untested
  • ActiveStorageAttachment is untested

Ungrouped

DistributionPdf (app/pdfs/distribution_pdf.rb) (98%)

  • Untested when Distribution has any line_items attached

DistributionUpdateService (app/services/distribution_update_service.rb) (96%)

  • #call Verify StandardError rescue branch

DiaperPartnerClient (app/services/diaper_partner_client.rb) (82%)

  • .add is untested

DistributionDestroyService (app/services/distribution_destroy_service.rb) (80%)

  • #call Verify StandardError rescue branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueSuitable for users that are newer or less experiencedHelp WantedGroomed + open to all!🔧 Tech DebtMaintance. We should pay this off someday!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions