diff options
author | Stan Hu <stanhu@gmail.com> | 2015-03-03 22:06:17 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-03-20 00:37:35 +0300 |
commit | 83d552d50d5485950052a8b9fcba384b81f33c43 (patch) | |
tree | 4cd793d3827467d70eae333df6acd1374aedfd1c /spec/lib/gitlab | |
parent | 6c1074e302fd77e87c454cede145dd92f15d0c55 (diff) |
Disable reference creation for comments surrounded by code/preformatted blocks
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/reference_extractor_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb index 034f8ee7c45..7e524aa95cf 100644 --- a/spec/lib/gitlab/reference_extractor_spec.rb +++ b/spec/lib/gitlab/reference_extractor_spec.rb @@ -50,6 +50,26 @@ describe Gitlab::ReferenceExtractor do expect(text).to eq('issue #123 is just the worst, @user') end + it 'extracts no references for <pre>..</pre> blocks' do + subject.analyze("<pre>def puts '#1 issue'\nend\n</pre>```", nil) + expect(subject.issues).to be_blank + end + + it 'extracts no references for <code>..</code> blocks' do + subject.analyze("<code>def puts '!1 request'\nend\n</code>```", nil) + expect(subject.merge_requests).to be_blank + end + + it 'extracts no references for code blocks with language' do + subject.analyze("this code:\n```ruby\ndef puts '#1 issue'\nend\n```", nil) + expect(subject.issues).to be_blank + end + + it 'extracts issue references for invalid code blocks' do + subject.analyze('test: ```this one talks about issue #1234```', nil) + expect(subject.issues).to eq([{ project: nil, id: '1234' }]) + end + it 'handles all possible kinds of references' do accessors = Gitlab::Markdown::TYPES.map { |t| "#{t}s".to_sym } expect(subject).to respond_to(*accessors) |