fixed pipeline notes issue
This commit is contained in:
parent
8c25399749
commit
f854f6cd02
3 changed files with 42 additions and 0 deletions
|
@ -170,6 +170,19 @@ module Ci
|
|||
builds.where.not(environment: nil).success.pluck(:environment).uniq
|
||||
end
|
||||
|
||||
# Manually set the notes for a Ci::Pipeline
|
||||
# There is no ActiveRecord relation between Ci::Pipeline and notes
|
||||
# as they are related to a commit sha. This method helps importing
|
||||
# them using the +Gitlab::ImportExport::RelationFactory+ class.
|
||||
def notes=(notes)
|
||||
notes.each do |note|
|
||||
note[:id] = nil
|
||||
note[:commit_id] = sha
|
||||
note[:noteable_id] = self['id']
|
||||
note.save!
|
||||
end
|
||||
end
|
||||
|
||||
def notes
|
||||
Note.for_commit_id(sha)
|
||||
end
|
||||
|
|
|
@ -4894,6 +4894,29 @@
|
|||
"started_at": null,
|
||||
"finished_at": null,
|
||||
"duration": null,
|
||||
"notes": [
|
||||
{
|
||||
"id": 999,
|
||||
"note": "Natus rerum qui dolorem dolorum voluptas.",
|
||||
"noteable_type": "Commit",
|
||||
"author_id": 1,
|
||||
"created_at": "2016-03-22T15:19:59.469Z",
|
||||
"updated_at": "2016-03-22T15:19:59.469Z",
|
||||
"project_id": 5,
|
||||
"attachment": {
|
||||
"url": null
|
||||
},
|
||||
"line_code": null,
|
||||
"commit_id": "be93687618e4b132087f430a4d8fc3a609c9b77c",
|
||||
"noteable_id": 36,
|
||||
"system": false,
|
||||
"st_diff": null,
|
||||
"updated_by_id": null,
|
||||
"author": {
|
||||
"name": "Administrator"
|
||||
}
|
||||
}
|
||||
],
|
||||
"statuses": [
|
||||
{
|
||||
"id": 71,
|
||||
|
|
|
@ -18,6 +18,12 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
|
|||
it 'restores models based on JSON' do
|
||||
expect(restored_project_json).to be true
|
||||
end
|
||||
|
||||
it 'creates a valid pipeline note' do
|
||||
restored_project_json
|
||||
|
||||
expect(Ci::Pipeline.first.notes).not_to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue