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
c754b693
Commit
c754b693
authored
Jun 01, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up presence validation spec
parent
f7f60ab5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+1
-2
spec/support/shared_examples/models/atomic_internal_id_spec.rb
...support/shared_examples/models/atomic_internal_id_spec.rb
+19
-9
No files found.
spec/models/ci/pipeline_spec.rb
View file @
c754b693
...
...
@@ -36,13 +36,12 @@ describe Ci::Pipeline, :mailer do
end
describe
'modules'
do
it_behaves_like
'AtomicInternalId'
do
it_behaves_like
'AtomicInternalId'
,
validate_presence:
false
do
let
(
:internal_id_attribute
)
{
:iid
}
let
(
:instance
)
{
build
(
:ci_pipeline
)
}
let
(
:scope
)
{
:project
}
let
(
:scope_attrs
)
{
{
project:
instance
.
project
}
}
let
(
:usage
)
{
:ci_pipelines
}
let
(
:allow_nil
)
{
true
}
end
end
...
...
spec/support/shared_examples/models/atomic_internal_id_spec.rb
View file @
c754b693
require
'spec_helper'
shared_examples_for
'AtomicInternalId'
do
let
(
:allow_nil
)
{
false
}
shared_examples_for
'AtomicInternalId'
do
|
validate_presence:
true
|
describe
'.has_internal_id'
do
describe
'Module inclusion'
do
subject
{
described_class
}
...
...
@@ -12,18 +10,30 @@ shared_examples_for 'AtomicInternalId' do
describe
'Validation'
do
before
do
allow_any_instance_of
(
described_class
).
to
receive
(
:"ensure_
#{
scope
}
_
#{
internal_id_attribute
}
!"
)
{}
end
allow_any_instance_of
(
described_class
).
to
receive
(
:"ensure_
#{
scope
}
_
#{
internal_id_attribute
}
!"
)
it
'validates presence'
do
instance
.
valid?
end
if
allow_nil
expect
(
instance
.
errors
[
internal_id_attribute
]).
to
be_empty
else
context
'when presence validattion is required'
do
before
do
skip
unless
validate_presence
end
it
'validates presence'
do
expect
(
instance
.
errors
[
internal_id_attribute
]).
to
include
(
"can't be blank"
)
end
end
context
'when presence validattion is not required'
do
before
do
skip
if
validate_presence
end
it
'does not validate presence'
do
expect
(
instance
.
errors
[
internal_id_attribute
]).
to
be_empty
end
end
end
describe
'Creating an instance'
do
...
...
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