Skip to content
代码片段 群组 项目
提交 3f7f3c95 编辑于 作者: Eulyeon Ko's avatar Eulyeon Ko 提交者: 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.
上级 c4d6756a
No related branches found
No related tags found
无相关合并请求
......@@ -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 @@ def find_model
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
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册