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
46fa3089
Commit
46fa3089
authored
May 11, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rescue RecordNotUnique when pipeline is created with non-unique iid
parent
910a7d02
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
14 deletions
+35
-14
lib/gitlab/ci/pipeline/chain/create.rb
lib/gitlab/ci/pipeline/chain/create.rb
+1
-1
spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
+27
-10
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+1
-1
spec/support/shared_examples/models/atomic_internal_id_spec.rb
...support/shared_examples/models/atomic_internal_id_spec.rb
+6
-2
No files found.
lib/gitlab/ci/pipeline/chain/create.rb
View file @
46fa3089
...
...
@@ -23,7 +23,7 @@ module Gitlab
end
end
end
rescue
ActiveRecord
::
RecordInvalid
=>
e
rescue
ActiveRecord
::
RecordInvalid
,
ActiveRecord
::
RecordNotUnique
=>
e
error
(
"Failed to persist the pipeline:
#{
e
}
"
)
end
...
...
spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
View file @
46fa3089
...
...
@@ -37,21 +37,38 @@ describe Gitlab::Ci::Pipeline::Chain::Create do
end
context
'when pipeline has validation errors'
do
let
(
:pipeline
)
do
build
(
:ci_pipeline
,
project:
project
,
ref:
nil
)
shared_examples_for
'expectations'
do
it
'breaks the chain'
do
expect
(
step
.
break?
).
to
be
true
end
it
'appends validation error'
do
expect
(
pipeline
.
errors
.
to_a
)
.
to
include
/Failed to persist the pipeline/
end
end
context
'when ref is nil'
do
let
(
:pipeline
)
do
build
(
:ci_pipeline
,
project:
project
,
ref:
nil
)
end
before
do
step
.
perform!
end
before
do
step
.
perform!
end
it
'breaks the chain'
do
expect
(
step
.
break?
).
to
be
true
it_behaves_like
'expectations'
end
it
'appends validation error'
do
expect
(
pipeline
.
errors
.
to_a
)
.
to
include
/Failed to persist the pipeline/
context
'when pipeline has a duplicate iid'
do
before
do
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:ensure_project_iid!
)
{
|
p
|
p
.
send
(
:write_attribute
,
:iid
,
1
)
}
create
(
:ci_pipeline
,
project:
project
)
step
.
perform!
end
it_behaves_like
'expectations'
end
end
end
spec/models/ci/pipeline_spec.rb
View file @
46fa3089
...
...
@@ -41,7 +41,7 @@ describe Ci::Pipeline, :mailer do
let
(
:instance
)
{
build
(
:ci_pipeline
)
}
let
(
:scope_attrs
)
{
{
project:
instance
.
project
}
}
let
(
:usage
)
{
:ci_pipelines
}
let
(
:
validate_presence
)
{
fals
e
}
let
(
:
allow_nil
)
{
tru
e
}
end
end
...
...
spec/support/shared_examples/models/atomic_internal_id_spec.rb
View file @
46fa3089
require
'spec_helper'
shared_examples_for
'AtomicInternalId'
do
let
(
:
validate_presence
)
{
tru
e
}
let
(
:
allow_nil
)
{
fals
e
}
describe
'.has_internal_id'
do
describe
'Module inclusion'
do
...
...
@@ -18,7 +18,11 @@ shared_examples_for 'AtomicInternalId' do
it
'validates presence'
do
instance
.
valid?
expect
(
instance
.
errors
[
:iid
]).
to
include
(
"can't be blank"
)
if
validate_presence
if
allow_nil
expect
(
instance
.
errors
[
:iid
]).
to
be_empty
else
expect
(
instance
.
errors
[
:iid
]).
to
include
(
"can't be blank"
)
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