2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2014-07-25 13:22:29 +08:00
|
|
|
require_dependency 'badge'
|
|
|
|
|
|
|
|
describe Badge do
|
2014-12-31 22:55:03 +08:00
|
|
|
it { is_expected.to belong_to(:badge_type) }
|
|
|
|
it { is_expected.to belong_to(:badge_grouping) }
|
|
|
|
it { is_expected.to have_many(:user_badges).dependent(:destroy) }
|
|
|
|
|
|
|
|
it { is_expected.to validate_presence_of(:name) }
|
|
|
|
it { is_expected.to validate_presence_of(:badge_type) }
|
|
|
|
it { is_expected.to validate_uniqueness_of(:name) }
|
2014-07-25 13:22:29 +08:00
|
|
|
|
|
|
|
it 'has a valid system attribute for new badges' do
|
2014-12-31 22:55:03 +08:00
|
|
|
expect(Badge.create!(name: "test", badge_type_id: 1).system?).to be false
|
2014-07-25 13:22:29 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|