diff --git a/app/models/badge.rb b/app/models/badge.rb index 72c3a4dc09b..aea3895c40a 100644 --- a/app/models/badge.rb +++ b/app/models/badge.rb @@ -1,5 +1,6 @@ class Badge < ActiveRecord::Base belongs_to :badge_type + has_many :user_badges, dependent: :destroy validates :name, presence: true, uniqueness: true validates :badge_type, presence: true diff --git a/spec/models/badge.rb b/spec/models/badge.rb index 3309f9ce077..8416fc854f0 100644 --- a/spec/models/badge.rb +++ b/spec/models/badge.rb @@ -4,6 +4,7 @@ require_dependency 'badge' describe Badge do it { should belong_to :badge_type } + it { should have_many(:user_badges).dependent(:destroy) } context 'validations' do before(:each) { Fabricate(:badge) }