Commit 4dbe58d3 authored by Achilleas Pipinellis's avatar Achilleas Pipinellis

Merge branch 'euko-update-loose-foreign-key-doc' into 'master'

Update the testing section in the loose foreign key doc

See merge request gitlab-org/gitlab!77652
parents 3d35d146 3f7f3c95
......@@ -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