Skip to content
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

Remove reminder's deletion from MedicationsController #2057

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

brunoocasali
Copy link
Member

This PR just improves code readability of reminders.

Part of issue 1601.

Related to: #1601

@brunoocasali brunoocasali force-pushed the enhancement/remove-dependent-from-controller branch from 7477373 to 062056b Compare December 14, 2021 11:49
.to(change(Medication, :count).by(-1))
expect(TakeMedicationReminder.active.count).to eq(0)
expect {
delete medication_path(medication)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve the readability of these tests, and fix some assertions after that.

let!(:medication) do
create(:medication, :with_daily_reminder, user: user)
end
let!(:medication) { create(:medication, user: user) }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an after creating a hook into the factories that creates a take_medication_reminder and a refill_reminder, as we have a has_one relation during the tests we have been creating two objects (2 take_medication_reminder and 2 refill_reminder) for the same medication, in other words, we are creating an inconsistency in the tests. So I fixed that here.

Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor! I didn't know about dependent: :destroy. Thanks, Bruno!

@julianguyen julianguyen merged commit 30d450c into main Dec 15, 2021
@delete-merged-branch delete-merged-branch bot deleted the enhancement/remove-dependent-from-controller branch December 15, 2021 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants