gitlab-org--gitlab-foss/spec/models/award_emoji_spec.rb

31 lines
871 B
Ruby
Raw Normal View History

2016-04-16 15:09:08 -04:00
require 'spec_helper'
describe AwardEmoji, models: true do
describe 'Associations' do
it { is_expected.to belong_to(:awardable) }
it { is_expected.to belong_to(:user) }
end
describe 'modules' do
it { is_expected.to include_module(Participable) }
end
describe "validations" do
it { is_expected.to validate_presence_of(:awardable) }
it { is_expected.to validate_presence_of(:user) }
it { is_expected.to validate_presence_of(:name) }
# To circumvent a bug in the shoulda matchers
describe "scoped uniqueness validation" do
it "rejects duplicate award emoji" do
user = create(:user)
issue = create(:issue)
create(:award_emoji, user: user, awardable: issue)
2016-06-01 05:23:09 -04:00
new_award = build(:award_emoji, user: user, awardable: issue)
2016-04-16 15:09:08 -04:00
expect(new_award).not_to be_valid
end
end
end
end