Destroy related lists when a label is removed
This commit is contained in:
parent
5317f6ea94
commit
e23d1706fa
2 changed files with 4 additions and 0 deletions
|
@ -13,6 +13,8 @@ class Label < ActiveRecord::Base
|
|||
default_value_for :color, DEFAULT_COLOR
|
||||
|
||||
belongs_to :project
|
||||
|
||||
has_many :lists, dependent: :destroy
|
||||
has_many :label_links, dependent: :destroy
|
||||
has_many :issues, through: :label_links, source: :target, source_type: 'Issue'
|
||||
has_many :merge_requests, through: :label_links, source: :target, source_type: 'MergeRequest'
|
||||
|
|
|
@ -5,8 +5,10 @@ describe Label, models: true do
|
|||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:project) }
|
||||
|
||||
it { is_expected.to have_many(:label_links).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:issues).through(:label_links).source(:target) }
|
||||
it { is_expected.to have_many(:lists).dependent(:destroy) }
|
||||
end
|
||||
|
||||
describe 'modules' do
|
||||
|
|
Loading…
Reference in a new issue