diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-30 12:08:57 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-30 12:08:57 +0000 |
commit | 1e254d9f5a46a85c9bb6f24da8265a30fd388db4 (patch) | |
tree | 7f9d414ae2256d96ee3d3ced3305da9507561c0c /spec/models/custom_emoji_spec.rb | |
parent | e860bae967a4fa90213ff1980fac0bea8f894366 (diff) | |
download | gitlab-ce-1e254d9f5a46a85c9bb6f24da8265a30fd388db4.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/custom_emoji_spec.rb')
-rw-r--r-- | spec/models/custom_emoji_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/models/custom_emoji_spec.rb b/spec/models/custom_emoji_spec.rb new file mode 100644 index 00000000000..2b569b6097d --- /dev/null +++ b/spec/models/custom_emoji_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe CustomEmoji do + describe 'Associations' do + it { is_expected.to belong_to(:namespace) } + it { is_expected.to have_db_column(:file) } + it { is_expected.to validate_length_of(:name).is_at_most(36) } + it { is_expected.to validate_presence_of(:name) } + end + + describe 'exclusion of duplicated emoji' do + let(:emoji_name) { Gitlab::Emoji.emojis_names.sample } + + it 'disallows emoji names of built-in emoji' do + new_emoji = build(:custom_emoji, name: emoji_name) + + expect(new_emoji).not_to be_valid + expect(new_emoji.errors.messages).to eq(name: ["#{emoji_name} is already being used for another emoji"]) + end + + it 'disallows duplicate custom emoji names within namespace' do + old_emoji = create(:custom_emoji) + new_emoji = build(:custom_emoji, name: old_emoji.name, namespace: old_emoji.namespace) + + expect(new_emoji).not_to be_valid + expect(new_emoji.errors.messages).to eq(name: ["has already been taken"]) + end + end +end |