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
1cc3f5c3
Commit
1cc3f5c3
authored
Mar 26, 2018
by
Olivier Gonzalez
Committed by
Dmitriy Zaporozhets
Mar 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make #base_pipeline returning the latest available pipeline for MR's base commit
parent
d5e8beb2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
app/models/merge_request.rb
app/models/merge_request.rb
+3
-1
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+20
-0
No files found.
app/models/merge_request.rb
View file @
1cc3f5c3
...
@@ -1107,7 +1107,9 @@ class MergeRequest < ActiveRecord::Base
...
@@ -1107,7 +1107,9 @@ class MergeRequest < ActiveRecord::Base
end
end
def
base_pipeline
def
base_pipeline
@base_pipeline
||=
project
.
pipelines
.
find_by
(
sha:
merge_request_diff
&
.
base_commit_sha
)
@base_pipeline
||=
project
.
pipelines
.
order
(
id: :desc
)
.
find_by
(
sha:
diff_base_sha
)
end
end
def
update_project_counter_caches
def
update_project_counter_caches
...
...
spec/models/merge_request_spec.rb
View file @
1cc3f5c3
...
@@ -2404,6 +2404,26 @@ describe MergeRequest do
...
@@ -2404,6 +2404,26 @@ describe MergeRequest do
end
end
end
end
describe
'#base_pipeline'
do
let
(
:pipeline_arguments
)
do
{
project:
project
,
ref:
merge_request
.
target_branch
,
sha:
merge_request
.
diff_base_sha
}
end
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let!
(
:first_pipeline
)
{
create
(
:ci_pipeline_without_jobs
,
pipeline_arguments
)
}
let!
(
:last_pipeline
)
{
create
(
:ci_pipeline_without_jobs
,
pipeline_arguments
)
}
it
'returns latest pipeline'
do
expect
(
merge_request
.
base_pipeline
).
to
eq
(
last_pipeline
)
end
end
describe
'#has_commits?'
do
describe
'#has_commits?'
do
before
do
before
do
allow
(
subject
.
merge_request_diff
).
to
receive
(
:commits_count
)
allow
(
subject
.
merge_request_diff
).
to
receive
(
:commits_count
)
...
...
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