Commit 00e42e3c authored by schwedenmut's avatar schwedenmut Committed by Rémy Coutable

Resolve "<link href=""> and <a href=""> not properly filled in activity RSS feed"

parent 4a3a7497
...@@ -110,10 +110,12 @@ module EventsHelper ...@@ -110,10 +110,12 @@ module EventsHelper
event.note_target) event.note_target)
elsif event.note? elsif event.note?
if event.note_target if event.note_target
event_note_target_path(event) event_note_target_url(event)
end end
elsif event.push? elsif event.push?
push_event_feed_url(event) push_event_feed_url(event)
elsif event.created_project?
project_url(event.project)
end end
end end
...@@ -145,14 +147,14 @@ module EventsHelper ...@@ -145,14 +147,14 @@ module EventsHelper
end end
end end
def event_note_target_path(event) def event_note_target_url(event)
if event.commit_note? if event.commit_note?
project_commit_path(event.project, event.note_target, anchor: dom_id(event.target)) project_commit_url(event.project, event.note_target, anchor: dom_id(event.target))
elsif event.project_snippet_note? elsif event.project_snippet_note?
project_snippet_path(event.project, event.note_target, anchor: dom_id(event.target)) project_snippet_url(event.project, event.note_target, anchor: dom_id(event.target))
else else
polymorphic_path([event.project.namespace.becomes(Namespace), polymorphic_url([event.project.namespace.becomes(Namespace),
event.project, event.note_target], event.project, event.note_target],
anchor: dom_id(event.target)) anchor: dom_id(event.target))
end end
end end
...@@ -166,7 +168,7 @@ module EventsHelper ...@@ -166,7 +168,7 @@ module EventsHelper
event.note_target_reference event.note_target_reference
end end
link_to(text, event_note_target_path(event), title: event.target_title, class: 'has-tooltip') link_to(text, event_note_target_url(event), title: event.target_title, class: 'has-tooltip')
else else
content_tag(:strong, '(deleted)') content_tag(:strong, '(deleted)')
end end
......
%div{ xmlns: "http://www.w3.org/1999/xhtml" } %div{ xmlns: "http://www.w3.org/1999/xhtml" }
%p %p
%strong= event.author_name %strong= event.author_name
= link_to "(#{truncate_sha(event.commit_id)})", project_commit_path(event.project, event.commit_id) = link_to "(#{truncate_sha(event.commit_id)})", event_feed_url(event)
%i %i
at at
= event.created_at.to_s(:short) = event.created_at.to_s(:short)
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
= event_action_name(event) = event_action_name(event)
%strong %strong
- if event.note? - if event.note?
= link_to event.note_target.to_reference, event_note_target_path(event), class: 'has-tooltip', title: event.target_title = link_to event.note_target.to_reference, event_note_target_url(event), class: 'has-tooltip', title: event.target_title
- elsif event.target - elsif event.target
= link_to event.target.to_reference, [event.project.namespace.becomes(Namespace), event.project, event.target], class: 'has-tooltip', title: event.target_title = link_to event.target.to_reference, [event.project.namespace.becomes(Namespace), event.project, event.target], class: 'has-tooltip', title: event.target_title
......
---
title: Fix links in RSS feed elements
merge_request: 21424
author: Marc Schwede
type: fixed
...@@ -25,4 +25,47 @@ describe EventsHelper do ...@@ -25,4 +25,47 @@ describe EventsHelper do
expect(helper.event_commit_title("foo & bar")).to eq("foo & bar") expect(helper.event_commit_title("foo & bar")).to eq("foo & bar")
end end
end end
describe '#event_feed_url' do
let(:event) { create(:event) }
let(:project) { create(:project, :public, :repository) }
it "returns project issue url" do
event.target = create(:issue)
expect(helper.event_feed_url(event)).to eq(project_issue_url(event.project, event.issue))
end
it "returns project merge_request url" do
event.target = create(:merge_request)
expect(helper.event_feed_url(event)).to eq(project_merge_request_url(event.project, event.merge_request))
end
it "returns project commit url" do
event.target = create(:note_on_commit, project: project)
expect(helper.event_feed_url(event)).to eq(project_commit_url(event.project, event.note_target))
end
it "returns event note target url" do
event.target = create(:note)
expect(helper.event_feed_url(event)).to eq(event_note_target_url(event))
end
it "returns project url" do
event.project = project
event.action = 1
expect(helper.event_feed_url(event)).to eq(project_url(event.project))
end
it "returns push event feed url" do
event = create(:push_event)
create(:push_event_payload, event: event, action: :pushed)
expect(helper.event_feed_url(event)).to eq(push_event_feed_url(event))
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment