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
3de4da57
Commit
3de4da57
authored
Apr 01, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
ed81ba53
d8258470
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
109 additions
and
16 deletions
+109
-16
app/models/merge_request.rb
app/models/merge_request.rb
+1
-2
app/services/merge_requests/merge_to_ref_service.rb
app/services/merge_requests/merge_to_ref_service.rb
+1
-3
app/views/layouts/nav/sidebar/_project.html.haml
app/views/layouts/nav/sidebar/_project.html.haml
+2
-2
changelogs/unreleased/58793-fix-nav-links-archived-project.yml
...elogs/unreleased/58793-fix-nav-links-archived-project.yml
+5
-0
changelogs/unreleased/check-mergeability-in-merge-to-ref-service.yml
...unreleased/check-mergeability-in-merge-to-ref-service.yml
+5
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+32
-0
spec/services/merge_requests/merge_to_ref_service_spec.rb
spec/services/merge_requests/merge_to_ref_service_spec.rb
+11
-9
spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+52
-0
No files found.
app/models/merge_request.rb
View file @
3de4da57
...
...
@@ -809,8 +809,7 @@ class MergeRequest < ApplicationRecord
end
def
mergeable_to_ref?
return
false
if
merged?
return
false
if
broken?
return
false
unless
mergeable_state?
(
skip_ci_check:
true
,
skip_discussions_check:
true
)
# Given the `merge_ref_path` will have the same
# state the `target_branch` would have. Ideally
...
...
app/services/merge_requests/merge_to_ref_service.rb
View file @
3de4da57
...
...
@@ -41,9 +41,7 @@ module MergeRequests
super
error
=
if
Feature
.
disabled?
(
:merge_to_tmp_merge_ref_path
,
project
)
'Feature is not enabled'
elsif
!
hooks_validation_pass?
(
merge_request
)
if
!
hooks_validation_pass?
(
merge_request
)
hooks_validation_error
(
merge_request
)
elsif
!
@merge_request
.
mergeable_to_ref?
"Merge request is not mergeable to
#{
target_ref
}
"
...
...
app/views/layouts/nav/sidebar/_project.html.haml
View file @
3de4da57
...
...
@@ -376,12 +376,12 @@
=
link_to
project_settings_repository_path
(
@project
),
title:
_
(
'Repository'
)
do
%span
=
_
(
'Repository'
)
-
if
@project
.
feature_available?
(
:builds
,
current_user
)
-
if
!
@project
.
archived?
&&
@project
.
feature_available?
(
:builds
,
current_user
)
=
nav_link
(
controller: :ci_cd
)
do
=
link_to
project_settings_ci_cd_path
(
@project
),
title:
_
(
'CI / CD'
)
do
%span
=
_
(
'CI / CD'
)
-
if
settings_operations_available?
-
if
!
@project
.
archived?
&&
settings_operations_available?
=
nav_link
(
controller:
[
:operations
])
do
=
link_to
project_settings_operations_path
(
@project
),
title:
_
(
'Operations'
)
do
=
_
(
'Operations'
)
...
...
changelogs/unreleased/58793-fix-nav-links-archived-project.yml
0 → 100644
View file @
3de4da57
---
title
:
"
Disable
inaccessible
navigation
links
upon
archiving
a
project"
merge_request
:
26020
author
:
Elias Werberich
type
:
fixed
changelogs/unreleased/check-mergeability-in-merge-to-ref-service.yml
0 → 100644
View file @
3de4da57
---
title
:
Check mergeability in MergeToRefService
merge_request
:
26757
author
:
type
:
changed
spec/models/merge_request_spec.rb
View file @
3de4da57
...
...
@@ -3089,6 +3089,38 @@ describe MergeRequest do
end
end
describe
'#mergeable_to_ref?'
do
it
'returns true when merge request is mergeable'
do
subject
=
create
(
:merge_request
)
expect
(
subject
.
mergeable_to_ref?
).
to
be
(
true
)
end
it
'returns false when merge request is already merged'
do
subject
=
create
(
:merge_request
,
:merged
)
expect
(
subject
.
mergeable_to_ref?
).
to
be
(
false
)
end
it
'returns false when merge request is closed'
do
subject
=
create
(
:merge_request
,
:closed
)
expect
(
subject
.
mergeable_to_ref?
).
to
be
(
false
)
end
it
'returns false when merge request is work in progress'
do
subject
=
create
(
:merge_request
,
title:
'WIP: The feature'
)
expect
(
subject
.
mergeable_to_ref?
).
to
be
(
false
)
end
it
'returns false when merge request has no commits'
do
subject
=
create
(
:merge_request
,
source_branch:
'empty-branch'
,
target_branch:
'master'
)
expect
(
subject
.
mergeable_to_ref?
).
to
be
(
false
)
end
end
describe
'#merge_participants'
do
it
'contains author'
do
expect
(
subject
.
merge_participants
).
to
eq
([
subject
.
author
])
...
...
spec/services/merge_requests/merge_to_ref_service_spec.rb
View file @
3de4da57
...
...
@@ -40,15 +40,6 @@ describe MergeRequests::MergeToRefService do
end
shared_examples_for
'successfully evaluates pre-condition checks'
do
it
'returns error when feature is disabled'
do
stub_feature_flags
(
merge_to_tmp_merge_ref_path:
false
)
result
=
service
.
execute
(
merge_request
)
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
'Feature is not enabled'
)
end
it
'returns an error when the failing to process the merge'
do
allow
(
project
.
repository
).
to
receive
(
:merge_to_ref
).
and_return
(
nil
)
...
...
@@ -180,6 +171,17 @@ describe MergeRequests::MergeToRefService do
it
{
expect
(
todo
).
not_to
be_done
}
end
context
'when merge request is WIP state'
do
it
'fails to merge'
do
merge_request
=
create
(
:merge_request
,
title:
'WIP: The feature'
)
result
=
service
.
execute
(
merge_request
)
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
"Merge request is not mergeable to
#{
merge_request
.
merge_ref_path
}
"
)
end
end
it
'returns error when user has no authorization to admin the merge request'
do
unauthorized_user
=
create
(
:user
)
project
.
add_reporter
(
unauthorized_user
)
...
...
spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
View file @
3de4da57
...
...
@@ -122,4 +122,56 @@ describe 'layouts/nav/sidebar/_project' do
end
end
end
describe
'ci/cd settings tab'
do
before
do
project
.
update!
(
archived:
project_archived
)
end
context
'when project is archived'
do
let
(
:project_archived
)
{
true
}
it
'does not show the ci/cd settings tab'
do
render
expect
(
rendered
).
not_to
have_link
(
'CI / CD'
,
href:
project_settings_ci_cd_path
(
project
))
end
end
context
'when project is active'
do
let
(
:project_archived
)
{
false
}
it
'shows the ci/cd settings tab'
do
render
expect
(
rendered
).
to
have_link
(
'CI / CD'
,
href:
project_settings_ci_cd_path
(
project
))
end
end
end
describe
'operations settings tab'
do
before
do
project
.
update!
(
archived:
project_archived
)
end
context
'when project is archived'
do
let
(
:project_archived
)
{
true
}
it
'does not show the operations settings tab'
do
render
expect
(
rendered
).
not_to
have_link
(
'Operations'
,
href:
project_settings_operations_path
(
project
))
end
end
context
'when project is active'
do
let
(
:project_archived
)
{
false
}
it
'shows the operations settings tab'
do
render
expect
(
rendered
).
to
have_link
(
'Operations'
,
href:
project_settings_operations_path
(
project
))
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