vkoves / carpe

Scheduling for the modern age - an UNMAINTAINED indigoBox project
http://carpe-uno.herokuapp.com
0 stars 0 forks source link

Fix Event Invites Authorization + Deleting "Special" Categories #424

Closed Watercycle closed 5 years ago

Watercycle commented 5 years ago

This PR fixes the issues mentioned here: https://github.com/vkoves/carpe/pull/414#pullrequestreview-224754682. Those issues being:

1) Deleting a category on My Schedule that is marked as the default event invite category (in Edit Profile) triggers a server error.

The easy fix to this problem was removing the foreign key on the default_event_invite_category_id column. User#event_invite_category! already implements logic for dealing with how a new default_event_invite_category is chosen.

2) Random users can invite people to one another's events.

This was just an oversight since the initial event invite functionality didn't originally include proper authorization. It has been fixed by adding CanCan authorize! to all relevant controller actions.

Type of Pull Request

Based on the [contributor's guide][contrib-guide], this PR is of type:

Requestor Checklist

Requestor: Put an x in all that apply. You can check boxes after the PR has been made.

Reviewer: If you see an item that is not checked that you believe should be, comment on that as part of your review.

How This Has Been Tested

1) Was tested by creating a user, creating a category, setting the category as the default event invite category, and then deleting that category on the schedule.

2) Was tested by adding additional controller tests.

Watercycle commented 5 years ago

Note: I moved the test event host shouldn't receive an event invitation email from the EventInvitesController tests to the EventsController tests since that is the controller that defines setup_hosting_event_path.

Watercycle commented 5 years ago

Just to clarify, there were some old tests that I split up because they were testing multiple things at once. I only added new tests for event invites.