Commit 71fc1e03 authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch 'fix-push-multiple-tags-atom' into 'master'

Fix atom feed with push events for multiple tags

See merge request gitlab-org/gitlab!62059
parents 2ae25491 cbf91d4b
...@@ -157,7 +157,7 @@ module EventsHelper ...@@ -157,7 +157,7 @@ module EventsHelper
project_commit_url(event.project, project_commit_url(event.project,
id: event.commit_to) id: event.commit_to)
end end
else elsif event.ref_name
project_commits_url(event.project, project_commits_url(event.project,
event.ref_name) event.ref_name)
end end
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
return unless event.visible_to_user?(current_user) return unless event.visible_to_user?(current_user)
event = event.present event = event.present
event_url = event_feed_url(event)
xml.entry do xml.entry do
xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}" 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.title truncate(event_feed_title(event), length: 80)
xml.updated event.updated_at.xmlschema xml.updated event.updated_at.xmlschema
......
- event_url = event_feed_url(event)
%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)})", event_feed_url(event) = link_to "(#{truncate_sha(event.commit_id)})", event_url if event_url
%i %i
at at
= event.created_at.to_s(:short) = 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 ...@@ -156,6 +156,12 @@ RSpec.describe Dashboard::ProjectsController, :aggregate_failures do
let!(:design_event) { create(:design_event, project: project) } let!(:design_event) { create(:design_event, project: project) }
let!(:wiki_page_event) { create(:wiki_page_event, project: project) } let!(:wiki_page_event) { create(:wiki_page_event, project: project) }
let!(:issue_event) { create(:closed_issue_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(:design) { design_event.design }
let(:wiki_page) { wiki_page_event.wiki_page } let(:wiki_page) { wiki_page_event.wiki_page }
let(:issue) { issue_event.issue } let(:issue) { issue_event.issue }
...@@ -168,9 +174,10 @@ RSpec.describe Dashboard::ProjectsController, :aggregate_failures do ...@@ -168,9 +174,10 @@ RSpec.describe Dashboard::ProjectsController, :aggregate_failures do
it 'renders all kinds of event without error' do it 'renders all kinds of event without error' do
get :index, format: :atom 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).to render_template('dashboard/projects/index')
expect(response.body).to include( expect(response.body).to include(
"pushed to project",
"uploaded design #{design.to_reference}", "uploaded design #{design.to_reference}",
"created wiki page #{wiki_page.title}", "created wiki page #{wiki_page.title}",
"joined project #{project.full_name}", "joined project #{project.full_name}",
......
...@@ -88,6 +88,13 @@ RSpec.describe EventsHelper do ...@@ -88,6 +88,13 @@ RSpec.describe EventsHelper do
expect(helper.event_feed_url(event)).to eq(push_event_feed_url(event)) expect(helper.event_feed_url(event)).to eq(push_event_feed_url(event))
end 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 end
describe '#event_preposition' do 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