diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/support/shared_examples/serializers/note_entity_shared_examples.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/support/shared_examples/serializers/note_entity_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/serializers/note_entity_shared_examples.rb | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/spec/support/shared_examples/serializers/note_entity_shared_examples.rb b/spec/support/shared_examples/serializers/note_entity_shared_examples.rb index a90a2dc3667..9af6ec45e49 100644 --- a/spec/support/shared_examples/serializers/note_entity_shared_examples.rb +++ b/spec/support/shared_examples/serializers/note_entity_shared_examples.rb @@ -5,8 +5,21 @@ RSpec.shared_examples 'note entity' do context 'basic note' do it 'exposes correct elements' do - expect(subject).to include(:type, :author, :note, :note_html, :current_user, :discussion_id, - :emoji_awardable, :award_emoji, :report_abuse_path, :attachment, :noteable_note_url, :resolvable) + expect(subject).to include( + :attachment, + :author, + :award_emoji, + :base_discussion, + :current_user, + :discussion_id, + :emoji_awardable, + :note, + :note_html, + :noteable_note_url, + :report_abuse_path, + :resolvable, + :type + ) end it 'does not expose elements for specific notes cases' do @@ -20,6 +33,39 @@ RSpec.shared_examples 'note entity' do it 'does not expose web_url for author' do expect(subject[:author]).not_to include(:web_url) end + + it 'exposes permission fields on current_user' do + expect(subject[:current_user]).to include(:can_edit, :can_award_emoji, :can_resolve, :can_resolve_discussion) + end + + describe ':can_resolve_discussion' do + context 'discussion is resolvable' do + before do + expect(note.discussion).to receive(:resolvable?).and_return(true) + end + + context 'user can resolve' do + it 'is true' do + expect(note.discussion).to receive(:can_resolve?).with(user).and_return(true) + expect(subject[:current_user][:can_resolve_discussion]).to be_truthy + end + end + + context 'user cannot resolve' do + it 'is false' do + expect(note.discussion).to receive(:can_resolve?).with(user).and_return(false) + expect(subject[:current_user][:can_resolve_discussion]).to be_falsey + end + end + end + + context 'discussion is not resolvable' do + it 'is false' do + expect(note.discussion).to receive(:resolvable?).and_return(false) + expect(subject[:current_user][:can_resolve_discussion]).to be_falsey + end + end + end end context 'when note was edited' do |