Specify `dependent: destroy` for UserBadges.

This commit is contained in:
Vikhyat Korrapati 2014-03-21 17:56:06 +05:30
parent 36cbd0d348
commit b1e524e9c3
2 changed files with 2 additions and 0 deletions

View File

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

View File

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