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
Boxiang Sun
gitlab-ce
Commits
24824cbb
Commit
24824cbb
authored
Mar 22, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Specs
parent
85f0b3a9
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
61 additions
and
24 deletions
+61
-24
changelogs/unreleased/issue_27168_2.yml
changelogs/unreleased/issue_27168_2.yml
+1
-1
features/steps/project/merge_requests.rb
features/steps/project/merge_requests.rb
+1
-0
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+2
-1
spec/features/cycle_analytics_spec.rb
spec/features/cycle_analytics_spec.rb
+4
-1
spec/features/issuables/issuable_list_spec.rb
spec/features/issuables/issuable_list_spec.rb
+3
-0
spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb
...es/merge_requests/merge_immediately_with_pipeline_spec.rb
+6
-4
spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb
...tures/merge_requests/merge_when_pipeline_succeeds_spec.rb
+4
-1
spec/features/merge_requests/mini_pipeline_graph_spec.rb
spec/features/merge_requests/mini_pipeline_graph_spec.rb
+1
-1
spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb
...merge_requests/only_allow_merge_if_build_succeeds_spec.rb
+2
-0
spec/features/merge_requests/widget_spec.rb
spec/features/merge_requests/widget_spec.rb
+13
-4
spec/lib/gitlab/cycle_analytics/events_spec.rb
spec/lib/gitlab/cycle_analytics/events_spec.rb
+4
-0
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+1
-1
spec/models/cycle_analytics/test_spec.rb
spec/models/cycle_analytics/test_spec.rb
+1
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+7
-9
spec/requests/projects/cycle_analytics_events_spec.rb
spec/requests/projects/cycle_analytics_events_spec.rb
+1
-0
spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb
...rge_requests/merge_when_pipeline_succeeds_service_spec.rb
+6
-0
spec/services/merge_requests/update_service_spec.rb
spec/services/merge_requests/update_service_spec.rb
+3
-1
No files found.
changelogs/unreleased/issue_27168_2.yml
View file @
24824cbb
---
title
:
Preloads head pipeline for
each merge request
title
:
Preloads head pipeline for
merge request collection
merge_request
:
author
:
features/steps/project/merge_requests.rb
View file @
24824cbb
...
...
@@ -544,6 +544,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
project
=
merge_request
.
source_project
project
.
enable_ci
pipeline
=
create
:ci_pipeline
,
project:
project
,
sha:
merge_request
.
diff_head_sha
,
ref:
merge_request
.
source_branch
merge_request
.
update
(
head_pipeline:
pipeline
)
create
:ci_build
,
pipeline:
pipeline
end
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
24824cbb
...
...
@@ -354,7 +354,8 @@ describe Projects::MergeRequestsController do
end
before
do
create
(
:ci_empty_pipeline
,
project:
project
,
sha:
merge_request
.
diff_head_sha
,
ref:
merge_request
.
source_branch
)
pipeline
=
create
(
:ci_empty_pipeline
,
project:
project
,
sha:
merge_request
.
diff_head_sha
,
ref:
merge_request
.
source_branch
)
merge_request
.
update
(
head_pipeline:
pipeline
)
end
it
'returns :merge_when_pipeline_succeeds'
do
...
...
spec/features/cycle_analytics_spec.rb
View file @
24824cbb
...
...
@@ -9,10 +9,13 @@ feature 'Cycle Analytics', feature: true, js: true do
let
(
:mr
)
{
create_merge_request_closing_issue
(
issue
,
commit_message:
"References
#{
issue
.
to_reference
}
"
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status:
'created'
,
project:
project
,
ref:
mr
.
source_branch
,
sha:
mr
.
source_branch_sha
)
}
before
{
mr
.
update
(
head_pipeline:
pipeline
)
}
context
'as an allowed user'
do
context
'when project is new'
do
before
do
project
.
team
<<
[
user
,
:master
]
project
.
add_master
(
user
)
mr
.
update
(
head_pipeline_id:
pipeline
.
id
)
login_as
(
user
)
visit
namespace_project_cycle_analytics_path
(
project
.
namespace
,
project
)
wait_for_ajax
...
...
spec/features/issuables/issuable_list_spec.rb
View file @
24824cbb
...
...
@@ -52,6 +52,9 @@ describe 'issuable list', feature: true do
create
(
:issue
,
project:
project
,
author:
user
)
else
create
(
:merge_request
,
source_project:
project
,
source_branch:
generate
(
:branch
))
source_branch
=
FFaker
::
Name
.
name
pipeline
=
create
(
:ci_empty_pipeline
,
project:
project
,
ref:
source_branch
,
status:
%w(running failed success)
.
sample
,
sha:
'any'
)
create
(
:merge_request
,
title:
FFaker
::
Lorem
.
sentence
,
source_project:
project
,
source_branch:
source_branch
,
head_pipeline:
pipeline
)
end
2
.
times
do
...
...
spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb
View file @
24824cbb
...
...
@@ -4,16 +4,18 @@ feature 'Merge immediately', :feature, :js do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:merge_request
)
do
let
!
(
:merge_request
)
do
create
(
:merge_request_with_diffs
,
source_project:
project
,
author:
user
,
title:
'Bug NS-04'
)
title:
'Bug NS-04'
,
head_pipeline:
pipeline
,
source_branch:
pipeline
.
ref
)
end
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
sha:
merge_request
.
diff_head_sha
,
ref:
merge_request
.
source_branch
)
ref:
'master'
,
sha:
project
.
repository
.
commit
(
'master'
).
id
)
end
before
{
project
.
team
<<
[
user
,
:master
]
}
...
...
spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb
View file @
24824cbb
...
...
@@ -16,7 +16,10 @@ feature 'Merge When Pipeline Succeeds', :feature, :js do
ref:
merge_request
.
source_branch
)
end
before
{
project
.
team
<<
[
user
,
:master
]
}
before
do
project
.
add_master
(
user
)
merge_request
.
update
(
head_pipeline_id:
pipeline
.
id
)
end
context
'when there is active pipeline for merge request'
do
background
do
...
...
spec/features/merge_requests/mini_pipeline_graph_spec.rb
View file @
24824cbb
...
...
@@ -3,7 +3,7 @@ require 'rails_helper'
feature
'Mini Pipeline Graph'
,
:js
,
:feature
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
head_pipeline:
pipeline
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
,
ref:
'master'
,
status:
'running'
,
sha:
project
.
commit
.
id
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
stage:
'test'
,
commands:
'test'
)
}
...
...
spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb
View file @
24824cbb
...
...
@@ -27,6 +27,8 @@ feature 'Only allow merge requests to be merged if the pipeline succeeds', featu
status:
status
)
end
before
{
merge_request
.
update
(
head_pipeline:
pipeline
)
}
context
'when merge requests can only be merged if the pipeline succeeds'
do
before
do
project
.
update_attribute
(
:only_allow_merge_if_pipeline_succeeds
,
true
)
...
...
spec/features/merge_requests/widget_spec.rb
View file @
24824cbb
...
...
@@ -89,6 +89,8 @@ describe 'Merge request', :feature, :js do
statuses:
[
commit_status
])
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
merge_request
.
update
(
head_pipeline_id:
pipeline
.
id
)
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
end
...
...
@@ -101,10 +103,15 @@ describe 'Merge request', :feature, :js do
context
'when merge request is in the blocked pipeline state'
do
before
do
create
(
:ci_pipeline
,
project:
project
,
pipeline
=
create
(
:ci_pipeline
,
project:
project
,
sha:
merge_request
.
diff_head_sha
,
ref:
merge_request
.
source_branch
,
status: :manual
)
status: :manual
)
merge_request
.
update
(
head_pipeline_id:
pipeline
.
id
)
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
...
...
@@ -129,6 +136,8 @@ describe 'Merge request', :feature, :js do
statuses:
[
commit_status
])
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
merge_request
.
update
(
head_pipeline_id:
pipeline
.
id
)
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
end
...
...
spec/lib/gitlab/cycle_analytics/events_spec.rb
View file @
24824cbb
...
...
@@ -130,6 +130,8 @@ describe 'cycle analytics events' do
end
before
do
merge_request
.
update
(
head_pipeline_id:
pipeline
.
id
)
create
(
:ci_build
,
pipeline:
pipeline
,
status: :success
,
author:
user
)
create
(
:ci_build
,
pipeline:
pipeline
,
status: :success
,
author:
user
)
...
...
@@ -226,6 +228,8 @@ describe 'cycle analytics events' do
end
before
do
merge_request
.
update
(
head_pipeline_id:
pipeline
.
id
)
create
(
:ci_build
,
pipeline:
pipeline
,
status: :success
,
author:
user
)
create
(
:ci_build
,
pipeline:
pipeline
,
status: :success
,
author:
user
)
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
24824cbb
...
...
@@ -85,6 +85,7 @@ merge_requests:
-
merge_requests_closing_issues
-
metrics
-
timelogs
-
head_pipeline
merge_request_diff
:
-
merge_request
pipelines
:
...
...
spec/models/ci/pipeline_spec.rb
View file @
24824cbb
...
...
@@ -1044,8 +1044,8 @@ describe Ci::Pipeline, models: true do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status:
'created'
,
project:
project
,
ref:
'master'
,
sha:
'a288a022a53a5a944fae87bcec6efc87b7061808'
)
}
it
"returns merge requests whose `diff_head_sha` matches the pipeline's SHA"
do
merge_request
=
create
(
:merge_request
,
source_project:
project
,
source_branch:
pipeline
.
ref
)
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:diff_head_sha
)
{
'a288a022a53a5a944fae87bcec6efc87b7061808'
}
merge_request
=
create
(
:merge_request
,
source_project:
project
,
head_pipeline:
pipeline
,
,
source_branch:
pipeline
.
ref
)
expect
(
pipeline
.
merge_requests
).
to
eq
([
merge_request
])
end
...
...
spec/models/cycle_analytics/test_spec.rb
View file @
24824cbb
...
...
@@ -14,6 +14,7 @@ describe 'CycleAnalytics#test', feature: true do
issue
=
context
.
create
(
:issue
,
project:
context
.
project
)
merge_request
=
context
.
create_merge_request_closing_issue
(
issue
)
pipeline
=
context
.
create
(
:ci_pipeline
,
ref:
merge_request
.
source_branch
,
sha:
merge_request
.
diff_head_sha
,
project:
context
.
project
)
merge_request
.
update
(
head_pipeline:
pipeline
)
{
pipeline:
pipeline
,
issue:
issue
}
end
,
start_time_conditions:
[[
"pipeline is started"
,
->
(
context
,
data
)
{
data
[
:pipeline
].
run!
}]],
...
...
spec/models/merge_request_spec.rb
View file @
24824cbb
...
...
@@ -760,13 +760,9 @@ describe MergeRequest, models: true do
describe
'#head_pipeline'
do
describe
'when the source project exists'
do
it
'returns the latest pipeline'
do
pipeline
=
double
(
:ci_pipeline
,
ref:
'master'
)
allow
(
subject
).
to
receive
(
:diff_head_sha
).
and_return
(
'123abc'
)
expect
(
subject
.
source_project
).
to
receive
(
:pipeline_for
).
with
(
'master'
,
'123abc'
).
and_return
(
pipeline
)
sha
=
"123abc"
pipeline
=
create
(
:ci_empty_pipeline
,
project:
subject
.
source_project
,
ref:
'master'
,
status:
'running'
,
sha:
sha
)
subject
.
update
(
head_pipeline:
pipeline
)
expect
(
subject
.
head_pipeline
).
to
eq
(
pipeline
)
end
...
...
@@ -1504,11 +1500,13 @@ describe MergeRequest, models: true do
describe
'#mergeable_with_slash_command?'
do
def
create_pipeline
(
status
)
create
(
:ci_pipeline_with_one_job
,
pipeline
=
create
(
:ci_pipeline_with_one_job
,
project:
project
,
ref:
merge_request
.
source_branch
,
sha:
merge_request
.
diff_head_sha
,
status:
status
)
merge_request
.
update
(
head_pipeline:
pipeline
)
end
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
,
only_allow_merge_if_pipeline_succeeds:
true
)
}
...
...
@@ -1594,7 +1592,7 @@ describe MergeRequest, models: true do
context
'with running pipeline'
do
before
do
create_pipeline
(
:running
)
merge_request
.
update
(
head_pipeline:
create_pipeline
(
:running
)
)
end
it
'is mergeable'
do
...
...
spec/requests/projects/cycle_analytics_events_spec.rb
View file @
24824cbb
...
...
@@ -122,6 +122,7 @@ describe 'cycle analytics events', api: true do
mr
=
create_merge_request_closing_issue
(
issue
,
commit_message:
"References
#{
issue
.
to_reference
}
"
)
pipeline
=
create
(
:ci_empty_pipeline
,
status:
'created'
,
project:
project
,
ref:
mr
.
source_branch
,
sha:
mr
.
source_branch_sha
)
mr
.
update
(
head_pipeline_id:
pipeline
.
id
)
pipeline
.
run
create
(
:ci_build
,
pipeline:
pipeline
,
status: :success
,
author:
user
)
...
...
spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb
View file @
24824cbb
...
...
@@ -82,6 +82,10 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
sha:
merge_request_head
,
status:
'success'
)
end
before
do
mr_merge_if_green_enabled
.
update
(
head_pipeline:
triggering_pipeline
)
end
it
"merges all merge requests with merge when the pipeline succeeds enabled"
do
expect
(
MergeWorker
).
to
receive
(
:perform_async
)
service
.
trigger
(
triggering_pipeline
)
...
...
@@ -124,6 +128,8 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
sha:
mr_conflict
.
diff_head_sha
,
status:
'success'
)
end
before
{
mr_conflict
.
update
(
head_pipeline_id:
conflict_pipeline
.
id
)
}
it
'does not merge the merge request'
do
expect
(
MergeWorker
).
not_to
receive
(
:perform_async
)
...
...
spec/services/merge_requests/update_service_spec.rb
View file @
24824cbb
...
...
@@ -174,11 +174,13 @@ describe MergeRequests::UpdateService, services: true do
context
'with active pipeline'
do
before
do
service_mock
=
double
create
(
:ci_pipeline_with_one_job
,
pipeline
=
create
(
:ci_pipeline_with_one_job
,
project:
project
,
ref:
merge_request
.
source_branch
,
sha:
merge_request
.
diff_head_sha
)
merge_request
.
update
(
head_pipeline_id:
pipeline
.
id
)
expect
(
MergeRequests
::
MergeWhenPipelineSucceedsService
).
to
receive
(
:new
).
with
(
project
,
user
).
and_return
(
service_mock
)
expect
(
service_mock
).
to
receive
(
:execute
).
with
(
merge_request
)
...
...
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