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

This commit is contained in:
schwedenmut 2018-09-05 11:29:04 +00:00 committed by Rémy Coutable
parent 4a3a749797
commit 00e42e3c45
5 changed files with 59 additions and 9 deletions

View file

@ -110,10 +110,12 @@ module EventsHelper
event.note_target)
elsif event.note?
if event.note_target
event_note_target_path(event)
event_note_target_url(event)
end
elsif event.push?
push_event_feed_url(event)
elsif event.created_project?
project_url(event.project)
end
end
@ -145,14 +147,14 @@ module EventsHelper
end
end
def event_note_target_path(event)
def event_note_target_url(event)
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?
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
polymorphic_path([event.project.namespace.becomes(Namespace),
event.project, event.note_target],
polymorphic_url([event.project.namespace.becomes(Namespace),
event.project, event.note_target],
anchor: dom_id(event.target))
end
end
@ -166,7 +168,7 @@ module EventsHelper
event.note_target_reference
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
content_tag(:strong, '(deleted)')
end

View file

@ -1,7 +1,7 @@
%div{ xmlns: "http://www.w3.org/1999/xhtml" }
%p
%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
at
= event.created_at.to_s(:short)

View file

@ -18,7 +18,7 @@
= event_action_name(event)
%strong
- 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
= link_to event.target.to_reference, [event.project.namespace.becomes(Namespace), event.project, event.target], class: 'has-tooltip', title: event.target_title

View file

@ -0,0 +1,5 @@
---
title: Fix links in RSS feed elements
merge_request: 21424
author: Marc Schwede
type: fixed

View file

@ -25,4 +25,47 @@ describe EventsHelper do
expect(helper.event_commit_title("foo & bar")).to eq("foo & bar")
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