Don't create description links for self-referencing work packages.

pull/561/head
Christian Rijke 11 years ago
parent f068b670e3
commit 630d7ed6b2
  1. 3
      app/helpers/application_helper.rb
  2. 30
      spec/helpers/application_helper_spec.rb

@ -734,7 +734,8 @@ module ApplicationHelper
end
elsif sep == '###'
oid = identifier.to_i
if work_package = WorkPackage.visible.find_by_id(oid, :include => :status)
work_package = WorkPackage.visible.find_by_id(oid, :include => :status)
if obj && work_package && obj.id != work_package.id
link = work_package_quick_info_with_description(work_package)
end
elsif sep == ':'

@ -317,6 +317,34 @@ describe ApplicationHelper do
it { should eq("<p>##{issue.id}.</p>") }
end
context "Cyclic Description Links" do
let(:issue2) { FactoryGirl.create :work_package,
:project => project,
:author => project_member,
:type => project.types.first }
before do
issue2.description = "####{issue.id}"
issue2.save!
issue.description = "####{issue2.id}"
issue.save!
end
subject { textilizable issue, :description }
it "doesn't replace description links with a cycle" do
expect(subject).to match("###{issue.id}")
end
end
context "Description links" do
subject { textilizable issue, :description }
it "replaces the macro with the issue description" do
expect(subject).to eq("<p>#{issue.description}</p>")
end
end
end
context "Project links" do
@ -500,7 +528,7 @@ describe ApplicationHelper do
# escaping
'!source:/some/file' => 'source:/some/file',
# invalid expressions
'source:' => 'source:',
'source:' => 'source:'
}
end

Loading…
Cancel
Save