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

Add test spec to show unexpected revival of dependent records #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions spec/permanent_records/dependent_revival_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'spec_helper'

MUSKRATS_PER_HOLE = 3

describe PermanentRecords do
let(:hole_a) { Hole.create! }
let(:hole_b) { Hole.create! }

before do
# add muskrats to hole_a and hole_b
MUSKRATS_PER_HOLE.times do
hole_a.muskrats.create!
hole_b.muskrats.create!
end

# destroy both holes
hole_a.destroy
hole_b.destroy

# only revive one hole
hole_a.revive
end

describe 'revive dependent associations, and only dependent associations' do
it 'should revive muskrats of revived hole' do
expect(hole_a.reload).to_not be_deleted
expect(hole_a.muskrats.not_deleted.count).to eq MUSKRATS_PER_HOLE
end

it 'should not revive muskrats of non-revived hole' do
expect(hole_b.reload).to be_deleted
expect(hole_b.muskrats.not_deleted.count).to eq 0
end
end
end