-
Notifications
You must be signed in to change notification settings - Fork 572
Stafftools delete groups and groupings #839
Stafftools delete groups and groupings #839
Conversation
9a6a78d to
e111098
Compare
tarebyte
left a comment
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.
Overall this is looking good, left a bit of feedback.
Thanks for tackling this!
| def destroy | ||
| org = @grouping.organization | ||
|
|
||
| GroupAssignment.where(grouping: @grouping).each(&:destroy) |
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.
So this could actually be:
GroupAssignment.where(grouping: @grouping).destroy_all| def destroy | ||
| grouping = @group.grouping | ||
|
|
||
| @group.destroy |
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.
I think we'd like to handle the case where the group actually didn't get destroyed. Maybe something like?
if @group.destroy
flash[:success] = 'Group was destroyed'
redirect_to stafftools_grouping_path(grouping.id)
else
flash[:error] = 'Group was not destroyed'
render :show
end| <tr> | ||
| <td>Grouping</td> | ||
| <td><%= link_to @group.grouping.title, stafftools_grouping_path(@group.grouping) %></td> | ||
| <td><%= link_to @group.grouping.title, stafftools_grouping_path(@group.grouping.id) %></td> |
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.
Nice 👍
|
|
||
| let(:grouping) { Grouping.create(organization: organization, title: 'Grouping 1') } | ||
|
|
||
| let!(:group_assignment) { |
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.
Is there a reason we need the ! here?
Also we can clean this up a bit:
let(:group_assignment) do
create(:group_assignment, creator: user, organization: organization, grouping: grouping)
endThere 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.
Did let! for eager-evaluation, so that the assignment is created before the delete request runs in the test. Is there a better way to do this? For some reason the test is failing, but passing on my machine. Maybe your tidied version will work
| org = @grouping.organization | ||
|
|
||
| GroupAssignment.where(grouping: @grouping).each(&:destroy) | ||
| @grouping.destroy |
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.
Same comment as https://github.com/education/classroom/pull/839/files#r99513000
|
Thanks for the review, will make another commit in a bit |
f7559ba to
5d70d3d
Compare
|
@tarebyte Any clue why this test is failing? |
My best guess would be to try recreating the VCR cassettes and try pushing that up. |
|
Weird, pushed new cassettes and it still fails. I'll look at it when I have a bit more time |
6b065b9 to
8b178b3
Compare
0ead693 to
e3d9ed3
Compare
e3d9ed3 to
f580c25
Compare
|
@tarebyte finally got this sorted, sorry for the huuuuuge delay. I was still on a forked remote for some reason, so my changes were based off of a different repo and making weird things happen. All good now 👍 |
|
Ping @tarebyte for when you have time |
|
Tests fixed. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closes #813
Staff can now delete groups and groupings from stafftools.
Also fixed a small link bug similar to #837
I made
Grouping#destroyremove all group-assignments under it because some views we're assuming all group-assignments had a valid grouping, which seems valid. Instead of having this in the controller, should we move it to the model and give GroupAssignments adependant: :destroyrelationship with Grouping?@tarebyte