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

Friendship model: Dependent destroy doesn't work correctly on friend association #46

Open
lucasbiguet opened this issue Jul 31, 2017 · 0 comments

Comments

@lucasbiguet
Copy link

lucasbiguet commented Jul 31, 2017

When a friend or friendable is destroyed it should destroy all its friendships too. It works out of the box on the friendable relation but not on the friend one

Here is a set of specs illustrating the problem:

context "Callbacks" do
  let(:friend) { create :user }
  let(:friendable) { create :user }
  let!(:friendship) { HasFriendship::Friendship.create(friend: friend, friendable: friendable, status: "accepted") }

  it "destroys friendship on friend destroy" do
    # Spec doesn't pass :(
    expect { friend.destroy }.to change { HasFriendship::Friendship.count }.by(-1)
  end

  it "destroys friendship on friendable destroy" do
    # Spec succeeds
    expect { friendable.destroy }.to change { HasFriendship::Friendship.count }.by(-1)
  end
end

I will try to submit a PR if I can find time to work on this

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

No branches or pull requests

1 participant