diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-22 11:31:16 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-22 11:31:16 +0000 |
commit | 905c1110b08f93a19661cf42a276c7ea90d0a0ff (patch) | |
tree | 756d138db422392c00471ab06acdff92c5a9b69c /spec/lib/banzai/reference_parser/mentioned_user_parser_spec.rb | |
parent | 50d93f8d1686950fc58dda4823c4835fd0d8c14b (diff) | |
download | gitlab-ce-905c1110b08f93a19661cf42a276c7ea90d0a0ff.tar.gz |
Add latest changes from gitlab-org/gitlab@12-4-stable-ee
Diffstat (limited to 'spec/lib/banzai/reference_parser/mentioned_user_parser_spec.rb')
-rw-r--r-- | spec/lib/banzai/reference_parser/mentioned_user_parser_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/lib/banzai/reference_parser/mentioned_user_parser_spec.rb b/spec/lib/banzai/reference_parser/mentioned_user_parser_spec.rb new file mode 100644 index 00000000000..1be279375bd --- /dev/null +++ b/spec/lib/banzai/reference_parser/mentioned_user_parser_spec.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Banzai::ReferenceParser::MentionedUserParser do + include ReferenceParserHelpers + + let(:group) { create(:group, :private) } + let(:user) { create(:user) } + let(:new_user) { create(:user) } + let(:project) { create(:project, group: group, creator: user) } + let(:link) { empty_html_link } + + subject { described_class.new(Banzai::RenderContext.new(project, new_user)) } + + describe '#gather_references' do + context 'when the link has a data-group attribute' do + context 'using an existing group ID' do + before do + link['data-group'] = project.group.id.to_s + group.add_developer(new_user) + end + + it 'returns empty list of users' do + expect(subject.gather_references([link])).to eq([]) + end + end + end + + context 'when the link has a data-project attribute' do + context 'using an existing project ID' do + before do + link['data-project'] = project.id.to_s + project.add_developer(new_user) + end + + it 'returns empty list of users' do + expect(subject.gather_references([link])).to eq([]) + end + end + end + + context 'when the link has a data-user attribute' do + it 'returns an Array of users' do + link['data-user'] = user.id.to_s + + expect(subject.referenced_by([link])).to eq([user]) + end + end + end +end |