Commit cbf91d4b authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Fix atom feed with push events for multiple tags

When the push event is for multiple tags, we cannot generate a link
because we don't store the tags / refs.

Changelog: fixed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62059
parent 88b3beca
......@@ -157,7 +157,7 @@ module EventsHelper
project_commit_url(event.project,
id: event.commit_to)
end
else
elsif event.ref_name
project_commits_url(event.project,
event.ref_name)
end
......
......@@ -3,10 +3,11 @@
return unless event.visible_to_user?(current_user)
event = event.present
event_url = event_feed_url(event)
xml.entry do
xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}"
xml.link href: event_feed_url(event)
xml.link href: event_url if event_url
xml.title truncate(event_feed_title(event), length: 80)
xml.updated event.updated_at.xmlschema
......
- event_url = event_feed_url(event)
%div{ xmlns: "http://www.w3.org/1999/xhtml" }
%p
%strong= event.author_name
= link_to "(#{truncate_sha(event.commit_id)})", event_feed_url(event)
= link_to "(#{truncate_sha(event.commit_id)})", event_url if event_url
%i
at
= event.created_at.to_s(:short)
......
---
title: Fix atom feed with push events for multiple tags
merge_request: 62059
author:
type: fixed
......@@ -156,6 +156,12 @@ RSpec.describe Dashboard::ProjectsController, :aggregate_failures do
let!(:design_event) { create(:design_event, project: project) }
let!(:wiki_page_event) { create(:wiki_page_event, project: project) }
let!(:issue_event) { create(:closed_issue_event, project: project) }
let!(:push_event) do
create(:push_event, project: project).tap do |event|
create(:push_event_payload, event: event, ref_count: 2, ref: nil, ref_type: :tag, commit_count: 0, action: :pushed)
end
end
let(:design) { design_event.design }
let(:wiki_page) { wiki_page_event.wiki_page }
let(:issue) { issue_event.issue }
......@@ -168,9 +174,10 @@ RSpec.describe Dashboard::ProjectsController, :aggregate_failures do
it 'renders all kinds of event without error' do
get :index, format: :atom
expect(assigns(:events)).to include(design_event, wiki_page_event, issue_event)
expect(assigns(:events)).to include(design_event, wiki_page_event, issue_event, push_event)
expect(response).to render_template('dashboard/projects/index')
expect(response.body).to include(
"pushed to project",
"uploaded design #{design.to_reference}",
"created wiki page #{wiki_page.title}",
"joined project #{project.full_name}",
......
......@@ -88,6 +88,13 @@ RSpec.describe EventsHelper do
expect(helper.event_feed_url(event)).to eq(push_event_feed_url(event))
end
it 'returns nil for push event with multiple refs' do
event = create(:push_event)
create(:push_event_payload, event: event, ref_count: 2, ref: nil, ref_type: :tag, commit_count: 0, action: :pushed)
expect(helper.event_feed_url(event)).to eq(nil)
end
end
describe '#event_preposition' do
......
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