Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
f29c3047
Commit
f29c3047
authored
Jul 01, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use has_many relationship with events
parent
d6d0a355
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
19 deletions
+13
-19
app/models/concerns/eventable.rb
app/models/concerns/eventable.rb
+0
-15
app/models/issue.rb
app/models/issue.rb
+2
-1
app/models/merge_request.rb
app/models/merge_request.rb
+2
-1
app/models/milestone.rb
app/models/milestone.rb
+1
-1
app/models/note.rb
app/models/note.rb
+1
-1
lib/gitlab/import_export/relation_factory.rb
lib/gitlab/import_export/relation_factory.rb
+1
-0
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+6
-0
No files found.
app/models/concerns/eventable.rb
deleted
100644 → 0
View file @
d6d0a355
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!
if
event
.
data
event
.
save!
end
end
end
app/models/issue.rb
View file @
f29c3047
...
...
@@ -6,7 +6,6 @@ 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
...
...
@@ -20,6 +19,8 @@ class Issue < ActiveRecord::Base
belongs_to
:project
belongs_to
:moved_to
,
class_name:
'Issue'
has_many
:events
,
as: :target
,
dependent: :destroy
validates
:project
,
presence:
true
scope
:cared
,
->
(
user
)
{
where
(
assignee_id:
user
)
}
...
...
app/models/merge_request.rb
View file @
f29c3047
...
...
@@ -5,7 +5,6 @@ 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"
...
...
@@ -13,6 +12,8 @@ class MergeRequest < ActiveRecord::Base
has_one
:merge_request_diff
,
dependent: :destroy
has_many
:events
,
as: :target
,
dependent: :destroy
serialize
:merge_params
,
Hash
after_create
:create_merge_request_diff
,
unless: :importing
...
...
app/models/milestone.rb
View file @
f29c3047
...
...
@@ -11,13 +11,13 @@ class Milestone < ActiveRecord::Base
include
Referable
include
StripAttribute
include
Milestoneish
include
Eventable
belongs_to
:project
has_many
:issues
has_many
:labels
,
->
{
distinct
.
reorder
(
'labels.title'
)
},
through: :issues
has_many
:merge_requests
has_many
:participants
,
->
{
distinct
.
reorder
(
'users.name'
)
},
through: :issues
,
source: :assignee
has_many
:events
,
as: :target
,
dependent: :destroy
scope
:active
,
->
{
with_state
(
:active
)
}
scope
:closed
,
->
{
with_state
(
:closed
)
}
...
...
app/models/note.rb
View file @
f29c3047
...
...
@@ -5,7 +5,6 @@ class Note < ActiveRecord::Base
include
Mentionable
include
Awardable
include
Importable
include
Eventable
# Attribute containing rendered and redacted Markdown as generated by
# Banzai::ObjectRenderer.
...
...
@@ -22,6 +21,7 @@ class Note < ActiveRecord::Base
belongs_to
:updated_by
,
class_name:
"User"
has_many
:todos
,
dependent: :destroy
has_many
:events
,
as: :target
,
dependent: :destroy
delegate
:gfm_reference
,
:local_reference
,
to: :noteable
delegate
:name
,
to: :project
,
prefix:
true
...
...
lib/gitlab/import_export/relation_factory.rb
View file @
f29c3047
...
...
@@ -33,6 +33,7 @@ module Gitlab
update_user_references
update_project_references
reset_ci_tokens
if
@relation_name
==
'Ci::Trigger'
@relation_hash
[
'data'
].
deep_symbolize_keys!
if
@relation_name
==
:events
&&
@relation_hash
[
'data'
]
generate_imported_object
end
...
...
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
View file @
f29c3047
...
...
@@ -24,6 +24,12 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
expect
(
Ci
::
Pipeline
.
first
.
notes
).
not_to
be_empty
end
it
'restores the correct event'
do
restored_project_json
expect
(
Event
.
where
.
not
(
data:
nil
).
first
.
data
[
:ref
]).
not_to
be_empty
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment