diff options
author | Stan Hu <stanhu@gmail.com> | 2017-04-15 06:04:15 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-04-15 07:26:32 -0700 |
commit | e89d4741d38bdbb645d5bf92cfdac5d66e8438b0 (patch) | |
tree | 2550fc740433071ebb3fd71a850096efa045063b /spec/lib/banzai | |
parent | 309bab431075eabfb7a01300f946ce9eb5b6fb98 (diff) | |
download | gitlab-ce-e89d4741d38bdbb645d5bf92cfdac5d66e8438b0.tar.gz |
Fix regression in rendering Markdown references that do not existsh-fix-base-parser
Closes #30972
Diffstat (limited to 'spec/lib/banzai')
-rw-r--r-- | spec/lib/banzai/reference_parser/base_parser_spec.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/spec/lib/banzai/reference_parser/base_parser_spec.rb b/spec/lib/banzai/reference_parser/base_parser_spec.rb index a3141894c74..d5746107ee1 100644 --- a/spec/lib/banzai/reference_parser/base_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/base_parser_spec.rb @@ -114,8 +114,27 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do expect(hash).to eq({ link => user }) end - it 'returns an empty Hash when the list of nodes is empty' do - expect(subject.grouped_objects_for_nodes([], User, 'data-user')).to eq({}) + it 'returns an empty Hash when entry does not exist in the database' do + link = double(:link) + + expect(link).to receive(:has_attribute?). + with('data-user'). + and_return(true) + + expect(link).to receive(:attr). + with('data-user'). + and_return('1') + + nodes = [link] + bad_id = user.id + 100 + + expect(subject).to receive(:unique_attribute_values). + with(nodes, 'data-user'). + and_return([bad_id.to_s]) + + hash = subject.grouped_objects_for_nodes(nodes, User, 'data-user') + + expect(hash).to eq({}) end end |