diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-15 15:11:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-15 15:11:13 +0300 |
commit | ae27cd3c8824d0d7815ad9ba550ad249f7e298a6 (patch) | |
tree | b926ecf47418ab28a6c9a70f2f20cfe14091ff58 /spec/policies | |
parent | 33f96e8df089c2291010598c50ec6868ab8cb1ef (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/policies')
-rw-r--r-- | spec/policies/custom_emoji_policy_spec.rb | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/policies/custom_emoji_policy_spec.rb b/spec/policies/custom_emoji_policy_spec.rb new file mode 100644 index 00000000000..9538ef9bb4a --- /dev/null +++ b/spec/policies/custom_emoji_policy_spec.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe CustomEmojiPolicy do + let(:user) { create(:user) } + let(:group) { create(:group) } + let(:custom_emoji) { create(:custom_emoji, group: group) } + + let(:custom_emoji_permissions) do + [ + :create_custom_emoji, + :delete_custom_emoji + ] + end + + context 'custom emoji permissions' do + subject { described_class.new(user, custom_emoji) } + + context 'when user is' do + context 'a developer' do + before do + group.add_developer(user) + end + + it do + expect_allowed(:create_custom_emoji) + end + end + + context 'is maintainer' do + before do + group.add_maintainer(user) + end + + it do + expect_allowed(*custom_emoji_permissions) + end + end + + context 'is owner' do + before do + group.add_owner(user) + end + + it do + expect_allowed(*custom_emoji_permissions) + end + end + + context 'is developer and emoji creator' do + before do + group.add_developer(user) + custom_emoji.update_attribute(:creator, user) + end + + it do + expect_allowed(*custom_emoji_permissions) + end + end + + context 'is emoji creator but not a member of the group' do + before do + custom_emoji.update_attribute(:creator, user) + end + + it do + expect_disallowed(*custom_emoji_permissions) + end + end + end + end +end |