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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
647cbed2
Commit
647cbed2
authored
Oct 31, 2018
by
Sean McGivern
Committed by
Douglas Barbosa Alexandre
Oct 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove EE-specific code from 'Discussion' models
parent
5626a354
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
101 additions
and
31 deletions
+101
-31
app/models/concerns/noteable.rb
app/models/concerns/noteable.rb
+1
-1
app/models/diff_note.rb
app/models/diff_note.rb
+4
-2
app/models/discussion_note.rb
app/models/discussion_note.rb
+6
-2
app/models/legacy_diff_note.rb
app/models/legacy_diff_note.rb
+1
-5
app/models/merge_request.rb
app/models/merge_request.rb
+0
-3
app/models/milestone.rb
app/models/milestone.rb
+1
-3
app/models/note.rb
app/models/note.rb
+0
-6
app/models/personal_snippet.rb
app/models/personal_snippet.rb
+2
-4
app/models/project_snippet.rb
app/models/project_snippet.rb
+1
-4
app/models/system_note_metadata.rb
app/models/system_note_metadata.rb
+0
-1
ee/app/models/ee/discussion_note.rb
ee/app/models/ee/discussion_note.rb
+16
-0
ee/app/models/ee/legacy_diff_note.rb
ee/app/models/ee/legacy_diff_note.rb
+14
-0
ee/app/models/ee/merge_request.rb
ee/app/models/ee/merge_request.rb
+12
-0
ee/app/models/ee/milestone.rb
ee/app/models/ee/milestone.rb
+10
-0
ee/app/models/ee/note.rb
ee/app/models/ee/note.rb
+7
-0
ee/app/models/ee/personal_snippet.rb
ee/app/models/ee/personal_snippet.rb
+13
-0
ee/app/models/ee/project_snippet.rb
ee/app/models/ee/project_snippet.rb
+13
-0
No files found.
app/models/concerns/noteable.rb
View file @
647cbed2
...
...
@@ -25,7 +25,7 @@ module Noteable
end
def
supports_discussions?
DiscussionNote
::
NOTEABLE_TYPES
.
include?
(
base_class_name
)
DiscussionNote
.
noteable_types
.
include?
(
base_class_name
)
end
def
discussions_rendered_on_frontend?
...
...
app/models/diff_note.rb
View file @
647cbed2
...
...
@@ -8,12 +8,14 @@ class DiffNote < Note
include
DiffPositionableNote
include
Gitlab
::
Utils
::
StrongMemoize
NOTEABLE_TYPES
=
%w(MergeRequest Commit)
.
freeze
def
self
.
noteable_types
%w(MergeRequest Commit)
end
validates
:original_position
,
presence:
true
validates
:position
,
presence:
true
validates
:line_code
,
presence:
true
,
line_code:
true
,
if: :on_text?
validates
:noteable_type
,
inclusion:
{
in:
NOTEABLE_TYPES
}
validates
:noteable_type
,
inclusion:
{
in:
noteable_types
}
validate
:positions_complete
validate
:verify_supported
validate
:diff_refs_match_commit
,
if: :for_commit?
...
...
app/models/discussion_note.rb
View file @
647cbed2
...
...
@@ -4,10 +4,14 @@
#
# A note of this type can be resolvable.
class
DiscussionNote
<
Note
prepend
EE
::
DiscussionNote
# Names of all implementers of `Noteable` that support discussions.
NOTEABLE_TYPES
=
%w(MergeRequest Issue Commit Snippet Epic)
.
freeze
def
self
.
noteable_types
%w(MergeRequest Issue Commit Snippet)
end
validates
:noteable_type
,
inclusion:
{
in:
NOTEABLE_TYPES
}
validates
:noteable_type
,
inclusion:
{
in:
noteable_types
}
def
discussion_class
(
*
)
Discussion
...
...
app/models/legacy_diff_note.rb
View file @
647cbed2
...
...
@@ -7,11 +7,7 @@
#
# A note of this type is never resolvable.
class
LegacyDiffNote
<
Note
# Elastic search configuration (it does not support STI properly)
document_type
'doc'
index_name
[
Rails
.
application
.
class
.
parent_name
.
downcase
,
Rails
.
env
].
join
(
'-'
)
include
Elastic
::
NotesSearch
prepend
EE
::
LegacyDiffNote
include
NoteOnDiff
serialize
:st_diff
# rubocop:disable Cop/ActiveRecordSerialize
...
...
app/models/merge_request.rb
View file @
647cbed2
...
...
@@ -26,7 +26,6 @@ class MergeRequest < ActiveRecord::Base
:deleted_at
prepend
::
EE
::
MergeRequest
include
Elastic
::
MergeRequestsSearch
belongs_to
:target_project
,
class_name:
"Project"
belongs_to
:source_project
,
class_name:
"Project"
...
...
@@ -163,7 +162,6 @@ class MergeRequest < ActiveRecord::Base
validates
:merge_user
,
presence:
true
,
if: :merge_when_pipeline_succeeds?
,
unless: :importing?
validate
:validate_branches
,
unless:
[
:allow_broken
,
:importing?
,
:closed_without_fork?
]
validate
:validate_fork
,
unless: :closed_without_fork?
validate
:validate_approvals_before_merge
,
unless: :importing?
validate
:validate_target_project
,
on: :create
scope
:by_source_or_target_branch
,
->
(
branch_name
)
do
...
...
@@ -678,7 +676,6 @@ class MergeRequest < ActiveRecord::Base
end
def
mergeable?
(
skip_ci_check:
false
)
return
false
unless
approved?
return
false
unless
mergeable_state?
(
skip_ci_check:
skip_ci_check
)
check_if_can_be_merged
...
...
app/models/milestone.rb
View file @
647cbed2
...
...
@@ -15,11 +15,10 @@ class Milestone < ActiveRecord::Base
include
Sortable
include
Referable
include
StripAttribute
include
Elastic
::
MilestonesSearch
include
Milestoneish
include
Gitlab
::
SQL
::
Pattern
include
::
EE
::
Milestone
prepend
::
EE
::
Milestone
cache_markdown_field
:title
,
pipeline: :single_line
cache_markdown_field
:description
...
...
@@ -30,7 +29,6 @@ class Milestone < ActiveRecord::Base
has_internal_id
:iid
,
scope: :project
,
init:
->
(
s
)
{
s
&
.
project
&
.
milestones
&
.
maximum
(
:iid
)
}
has_internal_id
:iid
,
scope: :group
,
init:
->
(
s
)
{
s
&
.
group
&
.
milestones
&
.
maximum
(
:iid
)
}
has_many
:boards
has_many
:issues
has_many
:labels
,
->
{
distinct
.
reorder
(
'labels.title'
)
},
through: :issues
has_many
:merge_requests
...
...
app/models/note.rb
View file @
647cbed2
...
...
@@ -9,7 +9,6 @@ class Note < ActiveRecord::Base
include
Participable
include
Mentionable
include
Elastic
::
NotesSearch
include
Awardable
include
Importable
include
FasterCacheKeys
...
...
@@ -103,7 +102,6 @@ class Note < ActiveRecord::Base
mount_uploader
:attachment
,
AttachmentUploader
# Scopes
scope
:searchable
,
->
{
where
(
system:
false
)
}
scope
:for_commit_id
,
->
(
commit_id
)
{
where
(
noteable_type:
"Commit"
,
commit_id:
commit_id
)
}
scope
:system
,
->
{
where
(
system:
true
)
}
scope
:user
,
->
{
where
(
system:
false
)
}
...
...
@@ -200,10 +198,6 @@ class Note < ActiveRecord::Base
end
end
def
searchable?
!
system
end
# rubocop: disable CodeReuse/ServiceClass
def
cross_reference?
return
unless
system
?
...
...
app/models/personal_snippet.rb
View file @
647cbed2
# frozen_string_literal: true
class
PersonalSnippet
<
Snippet
# Elastic search configuration (it does not support STI)
document_type
'doc'
index_name
[
Rails
.
application
.
class
.
parent_name
.
downcase
,
Rails
.
env
].
join
(
'-'
)
include
Elastic
::
SnippetsSearch
prepend
EE
::
PersonalSnippet
include
WithUploads
end
app/models/project_snippet.rb
View file @
647cbed2
# frozen_string_literal: true
class
ProjectSnippet
<
Snippet
# Elastic search configuration (it does not support STI)
document_type
'doc'
index_name
[
Rails
.
application
.
class
.
parent_name
.
downcase
,
Rails
.
env
].
join
(
'-'
)
include
Elastic
::
SnippetsSearch
prepend
EE
::
ProjectSnippet
belongs_to
:project
belongs_to
:author
,
class_name:
"User"
...
...
app/models/system_note_metadata.rb
View file @
647cbed2
...
...
@@ -11,7 +11,6 @@ class SystemNoteMetadata < ActiveRecord::Base
TYPES_WITH_CROSS_REFERENCES
=
%w[
commit cross_reference
close duplicate
relate unrelate
moved
]
.
freeze
...
...
ee/app/models/ee/discussion_note.rb
0 → 100644
View file @
647cbed2
# frozen_string_literal: true
module
EE
module
DiscussionNote
extend
ActiveSupport
::
Concern
class_methods
do
extend
::
Gitlab
::
Utils
::
Override
override
:noteable_types
def
noteable_types
super
+
%w(Epic)
end
end
end
end
ee/app/models/ee/legacy_diff_note.rb
0 → 100644
View file @
647cbed2
# frozen_string_literal: true
module
EE
module
LegacyDiffNote
extend
ActiveSupport
::
Concern
prepended
do
# Elastic search configuration (it does not support STI properly)
document_type
'doc'
index_name
[
Rails
.
application
.
class
.
parent_name
.
downcase
,
Rails
.
env
].
join
(
'-'
)
include
Elastic
::
NotesSearch
end
end
end
ee/app/models/ee/merge_request.rb
View file @
647cbed2
module
EE
module
MergeRequest
extend
ActiveSupport
::
Concern
extend
::
Gitlab
::
Utils
::
Override
include
::
Approvable
prepended
do
include
Elastic
::
MergeRequestsSearch
has_many
:approvals
,
dependent: :delete_all
# rubocop:disable Cop/ActiveRecordDependent
has_many
:approved_by_users
,
through: :approvals
,
source: :user
has_many
:approvers
,
as: :target
,
dependent: :delete_all
# rubocop:disable Cop/ActiveRecordDependent
has_many
:approver_groups
,
as: :target
,
dependent: :delete_all
# rubocop:disable Cop/ActiveRecordDependent
has_many
:draft_notes
validate
:validate_approvals_before_merge
,
unless: :importing?
delegate
:performance_artifact
,
to: :head_pipeline
,
prefix: :head
,
allow_nil:
true
delegate
:performance_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:license_management_artifact
,
to: :head_pipeline
,
prefix: :head
,
allow_nil:
true
...
...
@@ -24,6 +29,13 @@ module EE
participant
:participant_approvers
end
override
:mergeable?
def
mergeable?
(
skip_ci_check:
false
)
return
false
unless
approved?
super
end
def
supports_weight?
false
end
...
...
ee/app/models/ee/milestone.rb
View file @
647cbed2
# frozen_string_literal: true
module
EE
module
Milestone
extend
ActiveSupport
::
Concern
prepended
do
include
Elastic
::
MilestonesSearch
has_many
:boards
end
def
supports_weight?
parent
&
.
feature_available?
(
:issue_weights
)
end
...
...
ee/app/models/ee/note.rb
View file @
647cbed2
...
...
@@ -5,6 +5,13 @@ module EE
prepended
do
include
::
ObjectStorage
::
BackgroundMove
include
Elastic
::
NotesSearch
scope
:searchable
,
->
{
where
(
system:
false
)
}
end
def
searchable?
!
system
end
def
for_epic?
...
...
ee/app/models/ee/personal_snippet.rb
0 → 100644
View file @
647cbed2
# frozen_string_literal: true
module
EE
module
PersonalSnippet
extend
ActiveSupport
::
Concern
prepended
do
document_type
'doc'
index_name
[
Rails
.
application
.
class
.
parent_name
.
downcase
,
Rails
.
env
].
join
(
'-'
)
include
Elastic
::
SnippetsSearch
end
end
end
ee/app/models/ee/project_snippet.rb
0 → 100644
View file @
647cbed2
# frozen_string_literal: true
module
EE
module
ProjectSnippet
extend
ActiveSupport
::
Concern
prepended
do
document_type
'doc'
index_name
[
Rails
.
application
.
class
.
parent_name
.
downcase
,
Rails
.
env
].
join
(
'-'
)
include
Elastic
::
SnippetsSearch
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