Commit 5cb488e8 authored by Stan Hu's avatar Stan Hu

Fix Error 500 resulting when loading network graph

`discussion_id` may not be present when the SELECT call for notes
does not include this attribute. Don't attempt to set the discussion ID
unless the model contains the attribute.

Closes #21119, #21128
parent 6a05f246
......@@ -259,6 +259,8 @@ class Note < ActiveRecord::Base
def ensure_discussion_id
return unless self.persisted?
# Needed in case the SELECT statement doesn't ask for `discussion_id`
return unless self.has_attribute?(:discussion_id)
return if self.discussion_id
set_discussion_id
......
require 'spec_helper'
describe Network::Graph, models: true do
let(:project) { create(:project) }
let!(:note_on_commit) { create(:note_on_commit, project: project) }
it '#initialize' do
graph = described_class.new(project, 'refs/heads/master', project.repository.commit, nil)
expect(graph.notes).to eq( { note_on_commit.commit_id => 1 } )
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