Commit 3d2a7366 authored by James Lopez's avatar James Lopez

fixing events for import/export

parent 9e8fdead
module Eventable
extend ActiveSupport::Concern
def events
Event.where(target_id: id, target_type: self.class.to_s)
end
def events=(events)
events.each do |event|
event.target_id = id
event.data.deep_symbolize_keys!
event.save!
end
end
end
\ No newline at end of file
......@@ -6,6 +6,7 @@ class Issue < ActiveRecord::Base
include Referable
include Sortable
include Taskable
include Eventable
DueDateStruct = Struct.new(:title, :name).freeze
NoDueDate = DueDateStruct.new('No Due Date', '0').freeze
......
......@@ -5,6 +5,7 @@ class MergeRequest < ActiveRecord::Base
include Sortable
include Taskable
include Importable
include Eventable
belongs_to :target_project, foreign_key: :target_project_id, class_name: "Project"
belongs_to :source_project, foreign_key: :source_project_id, class_name: "Project"
......
......@@ -11,6 +11,7 @@ class Milestone < ActiveRecord::Base
include Referable
include StripAttribute
include Milestoneish
include Eventable
belongs_to :project
has_many :issues
......
......@@ -5,6 +5,7 @@ class Note < ActiveRecord::Base
include Mentionable
include Awardable
include Importable
include Eventable
# Attribute containing rendered and redacted Markdown as generated by
# Banzai::ObjectRenderer.
......
# Model relationships to be included in the project import/export
project_tree:
- issues:
- :events
- notes:
:author
- :author
- :events
- :labels
- :milestones
- milestones:
- :events
- snippets:
- notes:
:author
- :releases
- :events
- project_members:
- :user
- merge_requests:
- notes:
:author
- :author
- :events
- :merge_request_diff
- :events
- pipelines:
- notes:
:author
- :author
- :events
- :statuses
- :variables
- :triggers
......
......@@ -34,7 +34,7 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
end
it 'has events' do
expect(saved_project_json['events']).not_to be_empty
expect(saved_project_json['milestones'].first['events']).not_to be_empty
end
it 'has milestones' do
......@@ -132,7 +132,7 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
statuses: [commit_status])
create(:ci_build, pipeline: ci_pipeline, project: project)
create(:milestone, project: project)
milestone = create(:milestone, project: project)
create(:note, noteable: issue, project: project)
create(:note, noteable: merge_request, project: project)
create(:note, noteable: snippet, project: project)
......@@ -140,6 +140,9 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
author: user,
project: project,
commit_id: ci_pipeline.sha)
create(:event, target: milestone, project: project, action: Event::CREATED, author: user)
project
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