diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2017-07-20 11:34:09 +0200 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2017-08-01 07:26:58 +0200 |
commit | abb878326c5cac283fff19716149211658ce25d1 (patch) | |
tree | dde4804c2b877f3cf713cb405d0e2e336f9bdbf2 /spec/lib/banzai/filter/milestone_reference_filter_spec.rb | |
parent | 98615318883e37a4c9cb201e3e65bb7b775112cd (diff) | |
download | gitlab-ce-abb878326c5cac283fff19716149211658ce25d1.tar.gz |
Rename many path_with_namespace -> full_path
Diffstat (limited to 'spec/lib/banzai/filter/milestone_reference_filter_spec.rb')
-rw-r--r-- | spec/lib/banzai/filter/milestone_reference_filter_spec.rb | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb index 8fe05dc2e53..79ff9419e4b 100644 --- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb @@ -152,7 +152,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do let(:namespace) { create(:namespace) } let(:another_project) { create(:empty_project, :public, namespace: namespace) } let(:milestone) { create(:milestone, project: another_project) } - let(:reference) { "#{another_project.path_with_namespace}%#{milestone.iid}" } + let(:reference) { "#{another_project.full_path}%#{milestone.iid}" } let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do @@ -164,14 +164,14 @@ describe Banzai::Filter::MilestoneReferenceFilter do doc = reference_filter("See (#{reference}.)") expect(doc.css('a').first.text) - .to eq("#{milestone.name} in #{another_project.path_with_namespace}") + .to eq("#{milestone.name} in #{another_project.full_path}") end it 'has valid text' do doc = reference_filter("See (#{reference}.)") expect(doc.text) - .to eq("See (#{milestone.name} in #{another_project.path_with_namespace}.)") + .to eq("See (#{milestone.name} in #{another_project.full_path}.)") end it 'escapes the name attribute' do @@ -180,7 +180,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do doc = reference_filter("See #{reference}") expect(doc.css('a').first.text) - .to eq "#{milestone.name} in #{another_project.path_with_namespace}" + .to eq "#{milestone.name} in #{another_project.full_path}" end end @@ -189,7 +189,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do let(:project) { create(:empty_project, :public, namespace: namespace) } let(:another_project) { create(:empty_project, :public, namespace: namespace) } let(:milestone) { create(:milestone, project: another_project) } - let(:reference) { "#{another_project.path_with_namespace}%#{milestone.iid}" } + let(:reference) { "#{another_project.full_path}%#{milestone.iid}" } let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do @@ -257,4 +257,28 @@ describe Banzai::Filter::MilestoneReferenceFilter do .to eq "#{milestone.name} in #{another_project.path}" end end + + describe 'cross project milestone references' do + let(:another_project) { create(:empty_project, :public) } + let(:project_path) { another_project.full_path } + let(:milestone) { create(:milestone, project: another_project) } + let(:reference) { milestone.to_reference(project) } + + let!(:result) { reference_filter("See #{reference}") } + + it 'points to referenced project milestone page' do + expect(result.css('a').first.attr('href')).to eq urls + .project_milestone_url(another_project, milestone) + end + + it 'contains cross project content' do + expect(result.css('a').first.text).to eq "#{milestone.name} in #{project_path}" + end + + it 'escapes the name attribute' do + allow_any_instance_of(Milestone).to receive(:title).and_return(%{"></a>whatever<a title="}) + doc = reference_filter("See #{reference}") + expect(doc.css('a').first.text).to eq "#{milestone.name} in #{project_path}" + end + end end |