Commit 46cc034e authored by Douwe Maan's avatar Douwe Maan

Add resolved_at and resolved_by_id to DiffNote

parent 44ad0743
No related merge requests found
......@@ -4,11 +4,14 @@ class DiffNote < Note
serialize :original_position, Gitlab::Diff::Position
serialize :position, Gitlab::Diff::Position
belongs_to :resolved_by, class_name: "User"
validates :original_position, presence: true
validates :position, presence: true
validates :diff_line, presence: true
validates :line_code, presence: true, line_code: true
validates :noteable_type, inclusion: { in: ['Commit', 'MergeRequest'] }
validates :resolved_by, presence: true, if: :resolved?
validate :positions_complete
validate :verify_supported
......@@ -72,6 +75,16 @@ class DiffNote < Note
self.position.diff_refs == diff_refs
end
def resolvable?
!system? && !for_commit?
end
def resolved?
return false unless resolvable?
self.resolved_at.present?
end
private
def supported?
......
......@@ -128,6 +128,18 @@ class Note < ActiveRecord::Base
true
end
def resolvable?
false
end
def resolved?
false
end
def to_be_resolved?
resolvable? && !resolved?
end
def discussion_id
@discussion_id ||=
if for_merge_request?
......
class AddResolvedToNotes < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :notes, :resolved_at, :datetime
add_column :notes, :resolved_by_id, :integer
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160721081015) do
ActiveRecord::Schema.define(version: 20160724205507) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -705,6 +705,8 @@ ActiveRecord::Schema.define(version: 20160721081015) do
t.string "type"
t.text "position"
t.text "original_position"
t.datetime "resolved_at"
t.integer "resolved_by_id"
end
add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree
......
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