diff options
author | Zeger-Jan van de Weg <zegerjan@gitlab.com> | 2016-04-16 21:09:08 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <zegerjan@gitlab.com> | 2016-05-06 10:47:11 +0200 |
commit | 3bdc57f0a710b3769381ecad7ea4098223ecff56 (patch) | |
tree | abfe22d7d40c7d3e2912d659b045273254767dea /spec/models/award_emoji_spec.rb | |
parent | 05920a7964a039fd65d6b665c2ebd130d5ef949c (diff) | |
download | gitlab-ce-3bdc57f0a710b3769381ecad7ea4098223ecff56.tar.gz |
Create table for award emoji
Diffstat (limited to 'spec/models/award_emoji_spec.rb')
-rw-r--r-- | spec/models/award_emoji_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/models/award_emoji_spec.rb b/spec/models/award_emoji_spec.rb new file mode 100644 index 00000000000..fd3712b7d43 --- /dev/null +++ b/spec/models/award_emoji_spec.rb @@ -0,0 +1,31 @@ +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) } + it { is_expected.to validate_presence_of(:awardable) } + + # 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) + new_award = AwardEmoji.new(user: user, awardable: issue, name: "thumbsup") + + expect(new_award).not_to be_valid + end + end + end +end |