Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Conversation

@nwoodthorpe
Copy link
Contributor

@nwoodthorpe nwoodthorpe commented Feb 6, 2017

Closes #813

Staff can now delete groups and groupings from stafftools.

Also fixed a small link bug similar to #837

I made Grouping#destroy remove 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 a dependant: :destroy relationship with Grouping?

@tarebyte

screen shot 2017-02-05 at 4 50 33 pm

screen shot 2017-02-05 at 4 50 52 pm

@nwoodthorpe nwoodthorpe force-pushed the stafftools_delete_groups_and_groupings branch 2 times, most recently from 9a6a78d to e111098 Compare February 6, 2017 01:31
Copy link
Contributor

@tarebyte tarebyte left a 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)
Copy link
Contributor

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
Copy link
Contributor

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>
Copy link
Contributor

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) {
Copy link
Contributor

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)
end

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

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

@nwoodthorpe
Copy link
Contributor Author

Thanks for the review, will make another commit in a bit

@nwoodthorpe nwoodthorpe force-pushed the stafftools_delete_groups_and_groupings branch 2 times, most recently from f7559ba to 5d70d3d Compare February 15, 2017 04:58
@nwoodthorpe
Copy link
Contributor Author

@tarebyte Any clue why this test is failing? ./script/cibuild and rspec spec/controllers/stafftools/groupings_controller_spec.rb both pass locally, I can't figure out why Travis is having this error 😕

@tarebyte
Copy link
Contributor

Any clue why this test is failing? ./script/cibuild and rspec spec/controllers/stafftools/groupings_controller_spec.rb both pass locally, I can't figure out why Travis is having this error 😕

My best guess would be to try recreating the VCR cassettes and try pushing that up.

@nwoodthorpe
Copy link
Contributor Author

Weird, pushed new cassettes and it still fails. I'll look at it when I have a bit more time

@nwoodthorpe nwoodthorpe force-pushed the stafftools_delete_groups_and_groupings branch 3 times, most recently from 6b065b9 to 8b178b3 Compare February 26, 2017 23:45
@nwoodthorpe nwoodthorpe force-pushed the stafftools_delete_groups_and_groupings branch 2 times, most recently from 0ead693 to e3d9ed3 Compare March 25, 2017 05:33
@nwoodthorpe nwoodthorpe force-pushed the stafftools_delete_groups_and_groupings branch from e3d9ed3 to f580c25 Compare March 25, 2017 05:38
@nwoodthorpe
Copy link
Contributor Author

nwoodthorpe commented Mar 25, 2017

@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 👍

@nwoodthorpe
Copy link
Contributor Author

Ping @tarebyte for when you have time

@nwoodthorpe
Copy link
Contributor Author

Tests fixed.

@stale stale bot added the stale label Aug 12, 2017
@stale
Copy link

stale bot commented Aug 12, 2017

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.

@stale stale bot closed this Aug 20, 2017
@BenEmdon BenEmdon removed the wontfix label Oct 13, 2018
@d12 d12 reopened this Sep 18, 2019
@stale stale bot removed the stale label Sep 18, 2019
@spinecone spinecone requested a review from a team as a code owner September 27, 2019 19:06
@ghost ghost requested a review from jeffrafter September 27, 2019 19:07
spinecone added a commit that referenced this pull request Sep 30, 2019
@spinecone spinecone merged commit d689e22 into github-education-resources:master Sep 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow staff to delete Groups and Grouping

5 participants