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
06081856
Commit
06081856
authored
Feb 16, 2018
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `approved_by_users` relation to merge_requests
This could be a relation that is easily preloaded.
parent
25b0543c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
8 deletions
+9
-8
ee/app/controllers/ee/projects/merge_requests_controller.rb
ee/app/controllers/ee/projects/merge_requests_controller.rb
+5
-3
ee/app/models/concerns/approvable.rb
ee/app/models/concerns/approvable.rb
+1
-5
ee/app/models/ee/merge_request.rb
ee/app/models/ee/merge_request.rb
+1
-0
ee/spec/models/merge_request_spec.rb
ee/spec/models/merge_request_spec.rb
+1
-0
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-0
No files found.
ee/app/controllers/ee/projects/merge_requests_controller.rb
View file @
06081856
...
@@ -41,10 +41,12 @@ module EE
...
@@ -41,10 +41,12 @@ module EE
return
super
unless
APPROVAL_RENDERING_ACTIONS
.
include?
(
action_name
.
to_sym
)
return
super
unless
APPROVAL_RENDERING_ACTIONS
.
include?
(
action_name
.
to_sym
)
@issuable
=
@merge_request
||=
project
.
merge_requests
@issuable
=
@merge_request
||=
project
.
merge_requests
.
includes
(
approvals: :user
,
.
includes
(
approvers: :user
,
:approved_by_users
,
approver_groups: :group
)
approvers: :user
)
.
find_by!
(
iid:
params
[
:id
])
.
find_by!
(
iid:
params
[
:id
])
super
end
end
# rubocop:disable Gitlab/ModuleWithInstanceVariables
# rubocop:disable Gitlab/ModuleWithInstanceVariables
...
...
ee/app/models/concerns/approvable.rb
View file @
06081856
...
@@ -79,7 +79,7 @@ module Approvable
...
@@ -79,7 +79,7 @@ module Approvable
approvers_relation
=
approvers_overwritten?
?
approvers
:
target_project
.
approvers
approvers_relation
=
approvers_overwritten?
?
approvers
:
target_project
.
approvers
approvers_relation
=
approvers_relation
.
where
.
not
(
user_id:
author
.
id
)
if
author
approvers_relation
=
approvers_relation
.
where
.
not
(
user_id:
author
.
id
)
if
author
approvers_relation
approvers_relation
.
includes
(
:user
)
end
end
def
overall_approver_groups
def
overall_approver_groups
...
@@ -144,10 +144,6 @@ module Approvable
...
@@ -144,10 +144,6 @@ module Approvable
remaining_approvals
.
zero?
||
remaining_approvals
>
approvers_left
.
count
remaining_approvals
.
zero?
||
remaining_approvals
>
approvers_left
.
count
end
end
def
approved_by_users
approvals
.
map
(
&
:user
)
end
def
approver_ids
=
(
value
)
def
approver_ids
=
(
value
)
value
.
split
(
","
).
map
(
&
:strip
).
each
do
|
user_id
|
value
.
split
(
","
).
map
(
&
:strip
).
each
do
|
user_id
|
next
if
author
&&
user_id
==
author
.
id
next
if
author
&&
user_id
==
author
.
id
...
...
ee/app/models/ee/merge_request.rb
View file @
06081856
...
@@ -6,6 +6,7 @@ module EE
...
@@ -6,6 +6,7 @@ module EE
included
do
included
do
has_many
:approvals
,
dependent: :delete_all
# rubocop:disable Cop/ActiveRecordDependent
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
: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
:approver_groups
,
as: :target
,
dependent: :delete_all
# rubocop:disable Cop/ActiveRecordDependent
...
...
ee/spec/models/merge_request_spec.rb
View file @
06081856
...
@@ -11,6 +11,7 @@ describe MergeRequest do
...
@@ -11,6 +11,7 @@ describe MergeRequest do
it
{
is_expected
.
to
have_many
(
:approvals
).
dependent
(
:delete_all
)
}
it
{
is_expected
.
to
have_many
(
:approvals
).
dependent
(
:delete_all
)
}
it
{
is_expected
.
to
have_many
(
:approvers
).
dependent
(
:delete_all
)
}
it
{
is_expected
.
to
have_many
(
:approvers
).
dependent
(
:delete_all
)
}
it
{
is_expected
.
to
have_many
(
:approver_groups
).
dependent
(
:delete_all
)
}
it
{
is_expected
.
to
have_many
(
:approver_groups
).
dependent
(
:delete_all
)
}
it
{
is_expected
.
to
have_many
(
:approved_by_users
)
}
end
end
describe
'#squash_in_progress?'
do
describe
'#squash_in_progress?'
do
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
06081856
...
@@ -95,6 +95,7 @@ merge_requests:
...
@@ -95,6 +95,7 @@ merge_requests:
-
timelogs
-
timelogs
-
head_pipeline
-
head_pipeline
-
latest_merge_request_diff
-
latest_merge_request_diff
-
approved_by_users
merge_request_diff
:
merge_request_diff
:
-
merge_request
-
merge_request
-
merge_request_diff_commits
-
merge_request_diff_commits
...
...
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