created two new User instance methods: has_medication? and add_medication to clean up code in medications_controller#create. Wrote specs to match.
add_medication uses has_medication?as a check before creating theUserMedication` association to avoid duplicates.
created medications#get_symptoms to combine code from SearchResultsFacade and Medications controller into #save_symptoms to lighten up controller.
moved #save_symptoms from Medication to SearchResultsFacade
in medications_controller#create, now using find_or_create_by to make sure we aren't saving duplicates in the medication list.
added sad path test to features/dashboard/medications_spec.rb to check that duplicates aren't added to the med list.
when user tries to add a duplicate medication, they are redirected to medications/new page with a message saying "Sorry, you've already added to your list!"
Description
User
instance methods:has_medication?
andadd_medication
to clean up code inmedications_controller#create
. Wrote specs to match.add_medication
uses has_medication?as a check before creating the
UserMedication` association to avoid duplicates.medications#get_symptoms
to combine code from SearchResultsFacade and Medications controller into#save_symptoms
to lighten up controller.#save_symptoms
fromMedication
toSearchResultsFacade
medications_controller#create
, now usingfind_or_create_by
to make sure we aren't saving duplicates in the medication list.features/dashboard/medications_spec.rb
to check that duplicates aren't added to the med list.medications/new
page with a message saying "Sorry, you've already addedCloses issue(s)
Issue #38