diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2019-06-28 10:48:29 +0300 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2019-06-28 10:48:29 +0300 |
commit | f59a34a15f28a840670fa2fef5801aa31856d67b (patch) | |
tree | 7e0e53dfbeee535e93fdebcdd92f157d5d6997e7 /spec/policies | |
parent | 83ae09ad63c4b5e2a4c7c125961cc4a69bf22513 (diff) | |
parent | 4b9b2a43d02fc5154f780ade7fe76c02420fff15 (diff) |
Merge branch '62826-graphql-emoji-mutations' into 'master'
GraphQL mutations for add, remove and toggle emoji
See merge request gitlab-org/gitlab-ce!29919
Diffstat (limited to 'spec/policies')
-rw-r--r-- | spec/policies/award_emoji_policy_spec.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/policies/award_emoji_policy_spec.rb b/spec/policies/award_emoji_policy_spec.rb new file mode 100644 index 00000000000..2e3693c58d7 --- /dev/null +++ b/spec/policies/award_emoji_policy_spec.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe AwardEmojiPolicy do + let(:user) { create(:user) } + let(:award_emoji) { create(:award_emoji, awardable: awardable) } + + subject { described_class.new(user, award_emoji) } + + shared_examples 'when the user can read the awardable' do + context do + let(:project) { create(:project, :public) } + + it { expect_allowed(:read_emoji) } + end + end + + shared_examples 'when the user cannot read the awardable' do + context do + let(:project) { create(:project, :private) } + + it { expect_disallowed(:read_emoji) } + end + end + + context 'when the awardable is an issue' do + let(:awardable) { create(:issue, project: project) } + + include_examples 'when the user can read the awardable' + include_examples 'when the user cannot read the awardable' + end + + context 'when the awardable is a merge request' do + let(:awardable) { create(:merge_request, source_project: project) } + + include_examples 'when the user can read the awardable' + include_examples 'when the user cannot read the awardable' + end + + context 'when the awardable is a note' do + let(:awardable) { create(:note_on_merge_request, project: project) } + + include_examples 'when the user can read the awardable' + include_examples 'when the user cannot read the awardable' + end + + context 'when the awardable is a snippet' do + let(:awardable) { create(:project_snippet, :public, project: project) } + + include_examples 'when the user can read the awardable' + include_examples 'when the user cannot read the awardable' + end +end |