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
Léo-Paul Géneau
gitlab-ce
Commits
d9a2093e
Commit
d9a2093e
authored
Nov 28, 2016
by
Adam Niedzielski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent error when submitting a merge request and pipeline is not defined
parent
6ea0b8d5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
7 deletions
+45
-7
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
app/views/projects/merge_requests/_new_submit.html.haml
app/views/projects/merge_requests/_new_submit.html.haml
+5
-3
app/views/projects/merge_requests/_show.html.haml
app/views/projects/merge_requests/_show.html.haml
+3
-2
changelogs/unreleased/24860-actionview-template-error-undefined-method-size-for-nil-nilclass.yml
...template-error-undefined-method-size-for-nil-nilclass.yml
+4
-0
spec/views/projects/merge_requests/_new_submit.html.haml_spec.rb
...ews/projects/merge_requests/_new_submit.html.haml_spec.rb
+31
-0
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
d9a2093e
...
...
@@ -564,7 +564,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def
define_pipelines_vars
@pipelines
=
@merge_request
.
all_pipelines
@pipeline
=
@merge_request
.
pipeline
@statuses
=
@pipeline
.
statuses
.
relevant
if
@pipeline
.
present?
@statuses
_count
=
@pipeline
.
present?
?
@pipeline
.
statuses
.
relevant
.
count
:
0
end
def
define_new_vars
...
...
app/models/merge_request.rb
View file @
d9a2093e
...
...
@@ -781,7 +781,7 @@ class MergeRequest < ActiveRecord::Base
end
def
all_pipelines
return
unless
source_project
return
Ci
::
Pipeline
.
none
unless
source_project
@all_pipelines
||=
source_project
.
pipelines
.
where
(
sha:
all_commits_sha
,
ref:
source_branch
)
...
...
app/views/projects/merge_requests/_new_submit.html.haml
View file @
d9a2093e
...
...
@@ -34,10 +34,11 @@
=
link_to
url_for
(
params
),
data:
{
target:
'div#pipelines'
,
action:
'pipelines'
,
toggle:
'tab'
}
do
Pipelines
%span
.badge
=
@pipelines
.
size
-
if
@pipeline
.
present?
%li
.builds-tab
=
link_to
url_for
(
params
),
data:
{
target:
'div#builds'
,
action:
'builds'
,
toggle:
'tab'
}
do
Builds
%span
.badge
=
@statuses
.
size
%span
.badge
=
@statuses
_count
%li
.diffs-tab
=
link_to
url_for
(
params
.
merge
(
action:
'new_diffs'
)),
data:
{
target:
'div#diffs'
,
action:
'new/diffs'
,
toggle:
'tab'
}
do
Changes
...
...
@@ -48,9 +49,10 @@
=
render
"projects/merge_requests/show/commits"
#diffs
.diffs.tab-pane
-
# This tab is always loaded via AJAX
-
if
@pipeline
s
.
any
?
-
if
@pipeline
.
present
?
#builds
.builds.tab-pane
=
render
"projects/merge_requests/show/builds"
-
if
@pipelines
.
any?
#pipelines
.pipelines.tab-pane
=
render
"projects/merge_requests/show/pipelines"
...
...
@@ -65,5 +67,5 @@
:javascript
var
merge_request
=
new
MergeRequest
({
action
:
"
#{
(
@show_changes_tab
?
'new/diffs'
:
'new'
)
}
"
,
buildsLoaded
:
"
#{
@pipeline
s
.
any
?
?
'true'
:
'false'
}
"
buildsLoaded
:
"
#{
@pipeline
.
present
?
?
'true'
:
'false'
}
"
});
app/views/projects/merge_requests/_show.html.haml
View file @
d9a2093e
...
...
@@ -59,15 +59,16 @@
=
link_to
commits_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'div#commits'
,
action:
'commits'
,
toggle:
'tab'
}
do
Commits
%span
.badge
=
@commits_count
-
if
@pipeline
-
if
@pipeline
s
.
any?
%li
.pipelines-tab
=
link_to
pipelines_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'#pipelines'
,
action:
'pipelines'
,
toggle:
'tab'
}
do
Pipelines
%span
.badge
=
@pipelines
.
size
-
if
@pipeline
.
present?
%li
.builds-tab
=
link_to
builds_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'#builds'
,
action:
'builds'
,
toggle:
'tab'
}
do
Builds
%span
.badge
=
@statuses
.
size
%span
.badge
=
@statuses
_count
%li
.diffs-tab
=
link_to
diffs_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'div#diffs'
,
action:
'diffs'
,
toggle:
'tab'
}
do
Changes
...
...
changelogs/unreleased/24860-actionview-template-error-undefined-method-size-for-nil-nilclass.yml
0 → 100644
View file @
d9a2093e
---
title
:
Prevent error when submitting a merge request and pipeline is not defined
merge_request
:
7707
author
:
spec/views/projects/merge_requests/_new_submit.html.haml_spec.rb
0 → 100644
View file @
d9a2093e
require
'spec_helper'
describe
'projects/merge_requests/_new_submit.html.haml'
,
:view
do
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let!
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
before
do
controller
.
prepend_view_path
(
'app/views/projects'
)
assign
(
:merge_request
,
merge_request
)
assign
(
:commits
,
merge_request
.
commits
)
assign
(
:project
,
merge_request
.
target_project
)
allow
(
view
).
to
receive
(
:can?
).
and_return
(
true
)
allow
(
view
).
to
receive
(
:url_for
).
and_return
(
'#'
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
merge_request
.
author
)
end
context
'when there are pipelines for merge request but no pipeline for last commit'
do
before
do
assign
(
:pipelines
,
Ci
::
Pipeline
.
all
)
assign
(
:pipeline
,
nil
)
end
it
'shows <<Pipelines>> tab and hides <<Builds>> tab'
do
render
expect
(
rendered
).
to
have_text
(
'Pipelines 1'
)
expect
(
rendered
).
not_to
have_text
(
'Builds'
)
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