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
910a7d02
Commit
910a7d02
authored
May 11, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove numericality as it's redandant with integer column and validates nil IID
parent
9ccfcf55
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
3 deletions
+4
-3
app/models/concerns/atomic_internal_id.rb
app/models/concerns/atomic_internal_id.rb
+1
-1
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+1
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-0
spec/support/shared_examples/models/atomic_internal_id_spec.rb
...support/shared_examples/models/atomic_internal_id_spec.rb
+1
-2
No files found.
app/models/concerns/atomic_internal_id.rb
View file @
910a7d02
...
@@ -27,7 +27,7 @@ module AtomicInternalId
...
@@ -27,7 +27,7 @@ module AtomicInternalId
module
ClassMethods
module
ClassMethods
def
has_internal_id
(
column
,
scope
:,
init
:,
presence:
true
)
# rubocop:disable Naming/PredicateName
def
has_internal_id
(
column
,
scope
:,
init
:,
presence:
true
)
# rubocop:disable Naming/PredicateName
before_validation
:"ensure_
#{
scope
}
_
#{
column
}
!"
,
on: :create
before_validation
:"ensure_
#{
scope
}
_
#{
column
}
!"
,
on: :create
validates
column
,
presence:
presence
,
numericality:
true
validates
column
,
presence:
presence
define_method
(
"ensure_
#{
scope
}
_
#{
column
}
!"
)
do
define_method
(
"ensure_
#{
scope
}
_
#{
column
}
!"
)
do
scope_value
=
association
(
scope
).
reader
scope_value
=
association
(
scope
).
reader
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
910a7d02
...
@@ -228,6 +228,7 @@ Ci::Pipeline:
...
@@ -228,6 +228,7 @@ Ci::Pipeline:
-
config_source
-
config_source
-
failure_reason
-
failure_reason
-
protected
-
protected
-
iid
Ci::Stage:
Ci::Stage:
-
id
-
id
-
name
-
name
...
...
spec/models/ci/build_spec.rb
View file @
910a7d02
...
@@ -1517,6 +1517,7 @@ describe Ci::Build do
...
@@ -1517,6 +1517,7 @@ describe Ci::Build do
{
key:
'CI_PROJECT_URL'
,
value:
project
.
web_url
,
public:
true
},
{
key:
'CI_PROJECT_URL'
,
value:
project
.
web_url
,
public:
true
},
{
key:
'CI_PROJECT_VISIBILITY'
,
value:
'private'
,
public:
true
},
{
key:
'CI_PROJECT_VISIBILITY'
,
value:
'private'
,
public:
true
},
{
key:
'CI_PIPELINE_ID'
,
value:
pipeline
.
id
.
to_s
,
public:
true
},
{
key:
'CI_PIPELINE_ID'
,
value:
pipeline
.
id
.
to_s
,
public:
true
},
{
key:
'CI_PIPELINE_IID'
,
value:
pipeline
.
iid
.
to_s
,
public:
true
},
{
key:
'CI_CONFIG_PATH'
,
value:
pipeline
.
ci_yaml_file_path
,
public:
true
},
{
key:
'CI_CONFIG_PATH'
,
value:
pipeline
.
ci_yaml_file_path
,
public:
true
},
{
key:
'CI_PIPELINE_SOURCE'
,
value:
pipeline
.
source
,
public:
true
},
{
key:
'CI_PIPELINE_SOURCE'
,
value:
pipeline
.
source
,
public:
true
},
{
key:
'CI_COMMIT_MESSAGE'
,
value:
pipeline
.
git_commit_message
,
public:
true
},
{
key:
'CI_COMMIT_MESSAGE'
,
value:
pipeline
.
git_commit_message
,
public:
true
},
...
...
spec/support/shared_examples/models/atomic_internal_id_spec.rb
View file @
910a7d02
...
@@ -12,14 +12,13 @@ shared_examples_for 'AtomicInternalId' do
...
@@ -12,14 +12,13 @@ shared_examples_for 'AtomicInternalId' do
describe
'Validation'
do
describe
'Validation'
do
before
do
before
do
allow_any_instance_of
(
described_class
).
to
receive
(
:
ensure_iid!
)
{}
allow_any_instance_of
(
described_class
).
to
receive
(
:
"ensure_
#{
scope_attrs
.
keys
.
first
}
_
#{
internal_id_attribute
}
!"
)
{}
end
end
it
'validates presence'
do
it
'validates presence'
do
instance
.
valid?
instance
.
valid?
expect
(
instance
.
errors
[
:iid
]).
to
include
(
"can't be blank"
)
if
validate_presence
expect
(
instance
.
errors
[
:iid
]).
to
include
(
"can't be blank"
)
if
validate_presence
expect
(
instance
.
errors
[
:iid
]).
to
include
(
"is not a number"
)
# numericality
end
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