Destroy related lists when a label is removed

This commit is contained in:
Douglas Barbosa Alexandre 2016-08-08 16:14:22 -03:00
parent 5317f6ea94
commit e23d1706fa
2 changed files with 4 additions and 0 deletions

View file

@ -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'

View file

@ -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