summaryrefslogtreecommitdiff
path: root/spec/lib/banzai/filter
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-04-19 10:41:51 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-04-21 09:13:34 +0200
commitf7348cd348ad8f4a18d74dd668283a4e236f5790 (patch)
tree69e4bec7df80698fddf5c7877c0489210c5759c1 /spec/lib/banzai/filter
parent2ade37e2534108c72d28605cb131dacf771d27d3 (diff)
downloadgitlab-ce-f7348cd348ad8f4a18d74dd668283a4e236f5790.tar.gz
Fix cross-project label ref with invalid project
Closes #15168
Diffstat (limited to 'spec/lib/banzai/filter')
-rw-r--r--spec/lib/banzai/filter/label_reference_filter_spec.rb42
1 files changed, 26 insertions, 16 deletions
diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb
index 94468abcbb3..b0a38e7c251 100644
--- a/spec/lib/banzai/filter/label_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb
@@ -178,27 +178,37 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
end
describe 'cross project label references' do
- let(:another_project) { create(:empty_project, :public) }
- let(:project_name) { another_project.name_with_namespace }
- let(:label) { create(:label, project: another_project, color: '#00ff00') }
- let(:reference) { label.to_reference(project) }
+ context 'valid project referenced' do
+ let(:another_project) { create(:empty_project, :public) }
+ let(:project_name) { another_project.name_with_namespace }
+ let(:label) { create(:label, project: another_project, color: '#00ff00') }
+ let(:reference) { label.to_reference(project) }
- let!(:result) { reference_filter("See #{reference}") }
+ let!(:result) { reference_filter("See #{reference}") }
- it 'points to referenced project issues page' do
- expect(result.css('a').first.attr('href'))
- .to eq urls.namespace_project_issues_url(another_project.namespace,
- another_project,
- label_name: label.name)
- end
+ it 'points to referenced project issues page' do
+ expect(result.css('a').first.attr('href'))
+ .to eq urls.namespace_project_issues_url(another_project.namespace,
+ another_project,
+ label_name: label.name)
+ end
+
+ it 'has valid color' do
+ expect(result.css('a span').first.attr('style'))
+ .to match /background-color: #00ff00/
+ end
- it 'has valid color' do
- expect(result.css('a span').first.attr('style'))
- .to match /background-color: #00ff00/
+ it 'contains cross project content' do
+ expect(result.css('a').first.text).to eq "#{label.name} in #{project_name}"
+ end
end
- it 'contains cross project content' do
- expect(result.css('a').first.text).to eq "#{label.name} in #{project_name}"
+ context 'project that does not exist referenced' do
+ let(:result) { reference_filter('aaa/bbb~ccc') }
+
+ it 'does not link reference' do
+ expect(result.to_html).to eq 'aaa/bbb~ccc'
+ end
end
end
end