Merge pull request #2173 from vikhyat/badge-system

Forgot to specify "dependent: destroy" for UserBadges
This commit is contained in:
Sam 2014-03-25 08:25:31 +11:00
commit 4191972afe
2 changed files with 2 additions and 0 deletions

View File

@ -1,5 +1,6 @@
class Badge < ActiveRecord::Base class Badge < ActiveRecord::Base
belongs_to :badge_type belongs_to :badge_type
has_many :user_badges, dependent: :destroy
validates :name, presence: true, uniqueness: true validates :name, presence: true, uniqueness: true
validates :badge_type, presence: true validates :badge_type, presence: true

View File

@ -4,6 +4,7 @@ require_dependency 'badge'
describe Badge do describe Badge do
it { should belong_to :badge_type } it { should belong_to :badge_type }
it { should have_many(:user_badges).dependent(:destroy) }
context 'validations' do context 'validations' do
before(:each) { Fabricate(:badge) } before(:each) { Fabricate(:badge) }