summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/note.rb2
-rw-r--r--spec/models/network/graph_spec.rb12
2 files changed, 14 insertions, 0 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 3bbf5db0b70..f2656df028b 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -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
diff --git a/spec/models/network/graph_spec.rb b/spec/models/network/graph_spec.rb
new file mode 100644
index 00000000000..b76513d2a3c
--- /dev/null
+++ b/spec/models/network/graph_spec.rb
@@ -0,0 +1,12 @@
+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