Commit 3f7f3c95 authored by Eulyeon Ko's avatar Eulyeon Ko Committed by Achilleas Pipinellis

Update the loose foeign key documentation

Update the testing section to include
an example to test the loose foreign key
clean up behavior.
parent c4d6756a
......@@ -161,6 +161,17 @@ it_behaves_like 'it has loose foreign keys' do
end
```
**After** [removing a foreign key](#remove-the-foreign-key),
use the "`cleanup by a loose foreign key`" shared example to test a child record's deletion or nullification
via the added loose foreign key:
```ruby
it_behaves_like 'cleanup by a loose foreign key' do
let!(:model) { create(:ci_pipeline, user: create(:user)) }
let!(:parent) { model.user }
end
```
## Caveats of loose foreign keys
### Record creation
......
......@@ -59,7 +59,7 @@ RSpec.shared_examples 'cleanup by a loose foreign key' do
model.class.find_by(primary_key => model.public_send(primary_key))
end
it 'deletes the model' do
it 'cleans up (delete or nullify) the model' do
parent.delete
expect(find_model).to be_present
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment