Commit 6f8b9a16 authored by Sean McGivern's avatar Sean McGivern Committed by Jose Ivan Vargas

Merge branch 'sh-fix-atom-feeds' into 'master'

Fix 500 errors in Atom feeds due to push events

Closes #36705

See merge request !13695
parent 237d26b9
...@@ -83,6 +83,10 @@ class Event < ActiveRecord::Base ...@@ -83,6 +83,10 @@ class Event < ActiveRecord::Base
self.inheritance_column = 'action' self.inheritance_column = 'action'
class << self class << self
def model_name
ActiveModel::Name.new(self, nil, 'event')
end
def find_sti_class(action) def find_sti_class(action)
if action.to_i == PUSHED if action.to_i == PUSHED
PushEvent PushEvent
...@@ -438,6 +442,12 @@ class Event < ActiveRecord::Base ...@@ -438,6 +442,12 @@ class Event < ActiveRecord::Base
EventForMigration.create!(new_attributes) EventForMigration.create!(new_attributes)
end end
def to_partial_path
# We are intentionally using `Event` rather than `self.class` so that
# subclasses also use the `Event` implementation.
Event._to_partial_path
end
private private
def recent_update? def recent_update?
......
...@@ -41,6 +41,8 @@ describe "User Feed" do ...@@ -41,6 +41,8 @@ describe "User Feed" do
target_project: project, target_project: project,
description: "Here is the fix: ![an image](image.png)") description: "Here is the fix: ![an image](image.png)")
end end
let(:push_event) { create(:push_event, project: project, author: user) }
let!(:push_event_payload) { create(:push_event_payload, event: push_event) }
before do before do
project.team << [user, :master] project.team << [user, :master]
...@@ -70,6 +72,10 @@ describe "User Feed" do ...@@ -70,6 +72,10 @@ describe "User Feed" do
it 'has XHTML summaries in merge request descriptions' do it 'has XHTML summaries in merge request descriptions' do
expect(body).to match /Here is the fix: <a[^>]*><img[^>]*\/><\/a>/ expect(body).to match /Here is the fix: <a[^>]*><img[^>]*\/><\/a>/
end end
it 'has push event commit ID' do
expect(body).to have_content(Commit.truncate_sha(push_event.commit_id))
end
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