diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-05-15 23:07:25 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-05-26 22:49:20 +0300 |
commit | 81a09bc74cb997d3465f98cdcb72cacd413c31cd (patch) | |
tree | f7ad9d862653e2031da8c0de76cc269873323ecf /spec | |
parent | 35853033b9516aeffb6d341589406b00016947c3 (diff) |
Support only double quotes for multi-word label references
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/markdown/label_reference_filter_spec.rb | 54 | ||||
-rw-r--r-- | spec/models/label_spec.rb | 19 |
2 files changed, 28 insertions, 45 deletions
diff --git a/spec/lib/gitlab/markdown/label_reference_filter_spec.rb b/spec/lib/gitlab/markdown/label_reference_filter_spec.rb index 250a44d575d..41987f57bca 100644 --- a/spec/lib/gitlab/markdown/label_reference_filter_spec.rb +++ b/spec/lib/gitlab/markdown/label_reference_filter_spec.rb @@ -100,52 +100,26 @@ module Gitlab::Markdown end context 'String-based multi-word references in quotes' do - let(:label) { create(:label, name: 'gfm references', project: project) } + let(:label) { create(:label, name: 'gfm references', project: project) } + let(:reference) { label.to_reference(:name) } - context 'in single quotes' do - let(:reference) { "#{Label.reference_prefix}'#{label.name}'" } - - it 'links to a valid reference' do - doc = filter("See #{reference}") - - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_issues_url(project.namespace, project, label_name: label.name) - expect(doc.text).to eq 'See gfm references' - end - - it 'links with adjacent text' do - doc = filter("Label (#{reference}.)") - expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\.\))) - end - - it 'ignores invalid label names' do - exp = act = "Label #{Label.reference_prefix}'#{label.name.reverse}'" + it 'links to a valid reference' do + doc = filter("See #{reference}") - expect(filter(act).to_html).to eq exp - end + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.text).to eq 'See gfm references' end - context 'in double quotes' do - let(:reference) { %(#{Label.reference_prefix}"#{label.name}") } - - it 'links to a valid reference' do - doc = filter("See #{reference}") - - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_issues_url(project.namespace, project, label_name: label.name) - expect(doc.text).to eq 'See gfm references' - end - - it 'links with adjacent text' do - doc = filter("Label (#{reference}.)") - expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\.\))) - end + it 'links with adjacent text' do + doc = filter("Label (#{reference}.)") + expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\.\))) + end - it 'ignores invalid label names' do - exp = act = %(Label #{Label.reference_prefix}"#{label.name.reverse}") + it 'ignores invalid label names' do + exp = act = %(Label #{Label.reference_prefix}"#{label.name.reverse}") - expect(filter(act).to_html).to eq exp - end + expect(filter(act).to_html).to eq exp end end diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb index a13f9ac926c..6518213d71c 100644 --- a/spec/models/label_spec.rb +++ b/spec/models/label_spec.rb @@ -55,13 +55,22 @@ describe Label do end describe '#to_reference' do - it 'returns a String reference to the object' do - expect(label.to_reference).to eq "~#{label.id}" - expect(label.to_reference(double)).to eq "~#{label.id}" + context 'using id' do + it 'returns a String reference to the object' do + expect(label.to_reference).to eq "~#{label.id}" + expect(label.to_reference(double('project'))).to eq "~#{label.id}" + end end - it 'returns a String reference to the object using its name' do - expect(label.to_reference(:name)).to eq %(~"#{label.name}") + context 'using name' do + it 'returns a String reference to the object' do + expect(label.to_reference(:name)).to eq %(~"#{label.name}") + end + + it 'uses id when name contains double quote' do + label = create(:label, name: %q{"irony"}) + expect(label.to_reference(:name)).to eq "~#{label.id}" + end end end end |