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
dd4a8df4
Commit
dd4a8df4
authored
Dec 03, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate enum uniqueness
parent
a445aa0a
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
52 additions
and
0 deletions
+52
-0
spec/models/ci/build_metadata_spec.rb
spec/models/ci/build_metadata_spec.rb
+2
-0
spec/models/ci/build_trace_chunk_spec.rb
spec/models/ci/build_trace_chunk_spec.rb
+2
-0
spec/models/ci/job_artifact_spec.rb
spec/models/ci/job_artifact_spec.rb
+2
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+2
-0
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+2
-0
spec/models/ci/stage_spec.rb
spec/models/ci/stage_spec.rb
+2
-0
spec/models/clusters/applications/ingress_spec.rb
spec/models/clusters/applications/ingress_spec.rb
+1
-0
spec/models/clusters/cluster_spec.rb
spec/models/clusters/cluster_spec.rb
+2
-0
spec/models/clusters/platforms/kubernetes_spec.rb
spec/models/clusters/platforms/kubernetes_spec.rb
+2
-0
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+2
-0
spec/models/deployment_spec.rb
spec/models/deployment_spec.rb
+2
-0
spec/models/gpg_signature_spec.rb
spec/models/gpg_signature_spec.rb
+2
-0
spec/models/internal_id_spec.rb
spec/models/internal_id_spec.rb
+2
-0
spec/models/list_spec.rb
spec/models/list_spec.rb
+2
-0
spec/models/notification_setting_spec.rb
spec/models/notification_setting_spec.rb
+2
-0
spec/models/project_auto_devops_spec.rb
spec/models/project_auto_devops_spec.rb
+2
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+2
-0
spec/models/prometheus_metric_spec.rb
spec/models/prometheus_metric_spec.rb
+2
-0
spec/models/push_event_payload_spec.rb
spec/models/push_event_payload_spec.rb
+2
-0
spec/models/resource_label_event_spec.rb
spec/models/resource_label_event_spec.rb
+2
-0
spec/models/user_callout_spec.rb
spec/models/user_callout_spec.rb
+2
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+2
-0
spec/support/active_record_enum.rb
spec/support/active_record_enum.rb
+9
-0
No files found.
spec/models/ci/build_metadata_spec.rb
View file @
dd4a8df4
...
...
@@ -15,6 +15,8 @@ describe Ci::BuildMetadata do
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:build_metadata
)
{
build
.
metadata
}
it_behaves_like
'Unique enum values'
describe
'#update_timeout_state'
do
subject
{
build_metadata
}
...
...
spec/models/ci/build_trace_chunk_spec.rb
View file @
dd4a8df4
...
...
@@ -12,6 +12,8 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
described_class
.
new
(
build:
build
,
chunk_index:
chunk_index
,
data_store:
data_store
,
raw_data:
raw_data
)
end
it_behaves_like
'Unique enum values'
before
do
stub_feature_flags
(
ci_enable_live_trace:
true
)
stub_artifacts_object_storage
...
...
spec/models/ci/job_artifact_spec.rb
View file @
dd4a8df4
...
...
@@ -15,6 +15,8 @@ describe Ci::JobArtifact do
it
{
is_expected
.
to
delegate_method
(
:open
).
to
(
:file
)
}
it
{
is_expected
.
to
delegate_method
(
:exists?
).
to
(
:file
)
}
it_behaves_like
'Unique enum values'
describe
'.test_reports'
do
subject
{
described_class
.
test_reports
}
...
...
spec/models/ci/pipeline_spec.rb
View file @
dd4a8df4
...
...
@@ -28,6 +28,8 @@ describe Ci::Pipeline, :mailer do
it
{
is_expected
.
to
respond_to
:short_sha
}
it
{
is_expected
.
to
delegate_method
(
:full_path
).
to
(
:project
).
with_prefix
}
it_behaves_like
'Unique enum values'
describe
'associations'
do
it
'has a bidirectional relationship with projects'
do
expect
(
described_class
.
reflect_on_association
(
:project
).
has_inverse?
).
to
eq
(
:pipelines
)
...
...
spec/models/ci/runner_spec.rb
View file @
dd4a8df4
require
'spec_helper'
describe
Ci
::
Runner
do
it_behaves_like
'Unique enum values'
describe
'validation'
do
it
{
is_expected
.
to
validate_presence_of
(
:access_level
)
}
it
{
is_expected
.
to
validate_presence_of
(
:runner_type
)
}
...
...
spec/models/ci/stage_spec.rb
View file @
dd4a8df4
...
...
@@ -3,6 +3,8 @@ require 'spec_helper'
describe
Ci
::
Stage
,
:models
do
let
(
:stage
)
{
create
(
:ci_stage_entity
)
}
it_behaves_like
'Unique enum values'
describe
'associations'
do
before
do
create
(
:ci_build
,
stage_id:
stage
.
id
)
...
...
spec/models/clusters/applications/ingress_spec.rb
View file @
dd4a8df4
...
...
@@ -6,6 +6,7 @@ describe Clusters::Applications::Ingress do
include_examples
'cluster application core specs'
,
:clusters_applications_ingress
include_examples
'cluster application status specs'
,
:clusters_applications_ingress
include_examples
'cluster application helm specs'
,
:clusters_applications_ingress
it_behaves_like
'Unique enum values'
before
do
allow
(
ClusterWaitForIngressIpAddressWorker
).
to
receive
(
:perform_in
)
...
...
spec/models/clusters/cluster_spec.rb
View file @
dd4a8df4
...
...
@@ -30,6 +30,8 @@ describe Clusters::Cluster do
it
{
is_expected
.
to
respond_to
:project
}
it_behaves_like
'Unique enum values'
describe
'.enabled'
do
subject
{
described_class
.
enabled
}
...
...
spec/models/clusters/platforms/kubernetes_spec.rb
View file @
dd4a8df4
...
...
@@ -18,6 +18,8 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
it
{
is_expected
.
to
delegate_method
(
:managed?
).
to
(
:cluster
)
}
it
{
is_expected
.
to
delegate_method
(
:kubernetes_namespace
).
to
(
:cluster
)
}
it_behaves_like
'Unique enum values'
describe
'before_validation'
do
context
'when namespace includes upper case'
do
let
(
:kubernetes
)
{
create
(
:cluster_platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
...
...
spec/models/commit_status_spec.rb
View file @
dd4a8df4
...
...
@@ -29,6 +29,8 @@ describe CommitStatus do
it
{
is_expected
.
to
respond_to
:running?
}
it
{
is_expected
.
to
respond_to
:pending?
}
it_behaves_like
'Unique enum values'
describe
'#author'
do
subject
{
commit_status
.
author
}
...
...
spec/models/deployment_spec.rb
View file @
dd4a8df4
...
...
@@ -16,6 +16,8 @@ describe Deployment do
it
{
is_expected
.
to
validate_presence_of
(
:ref
)
}
it
{
is_expected
.
to
validate_presence_of
(
:sha
)
}
it_behaves_like
'Unique enum values'
describe
'#scheduled_actions'
do
subject
{
deployment
.
scheduled_actions
}
...
...
spec/models/gpg_signature_spec.rb
View file @
dd4a8df4
...
...
@@ -8,6 +8,8 @@ RSpec.describe GpgSignature do
let
(
:gpg_key
)
{
create
(
:gpg_key
)
}
let
(
:gpg_key_subkey
)
{
create
(
:gpg_key_subkey
)
}
it_behaves_like
'Unique enum values'
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:gpg_key
)
}
...
...
spec/models/internal_id_spec.rb
View file @
dd4a8df4
...
...
@@ -11,6 +11,8 @@ describe InternalId do
it
{
is_expected
.
to
validate_presence_of
(
:usage
)
}
end
it_behaves_like
'Unique enum values'
describe
'.generate_next'
do
subject
{
described_class
.
generate_next
(
issue
,
scope
,
usage
,
init
)
}
...
...
spec/models/list_spec.rb
View file @
dd4a8df4
...
...
@@ -21,6 +21,8 @@ describe List do
end
end
it_behaves_like
'Unique enum values'
describe
'#destroy'
do
it
'can be destroyed when list_type is set to label'
do
subject
=
create
(
:list
)
...
...
spec/models/notification_setting_spec.rb
View file @
dd4a8df4
...
...
@@ -6,6 +6,8 @@ RSpec.describe NotificationSetting do
it
{
is_expected
.
to
belong_to
(
:source
)
}
end
it_behaves_like
'Unique enum values'
describe
"Validation"
do
subject
{
described_class
.
new
(
source_id:
1
,
source_type:
'Project'
)
}
...
...
spec/models/project_auto_devops_spec.rb
View file @
dd4a8df4
...
...
@@ -10,6 +10,8 @@ describe ProjectAutoDevops do
it
{
is_expected
.
to
respond_to
(
:created_at
)
}
it
{
is_expected
.
to
respond_to
(
:updated_at
)
}
it_behaves_like
'Unique enum values'
describe
'#has_domain?'
do
context
'when domain is defined'
do
let
(
:auto_devops
)
{
build_stubbed
(
:project_auto_devops
,
project:
project
,
domain:
'domain.com'
)
}
...
...
spec/models/project_spec.rb
View file @
dd4a8df4
...
...
@@ -375,6 +375,8 @@ describe Project do
end
end
it_behaves_like
'Unique enum values'
describe
'Respond to'
do
it
{
is_expected
.
to
respond_to
(
:url_to_repo
)
}
it
{
is_expected
.
to
respond_to
(
:repo_exists?
)
}
...
...
spec/models/prometheus_metric_spec.rb
View file @
dd4a8df4
...
...
@@ -11,6 +11,8 @@ describe PrometheusMetric do
it
{
is_expected
.
to
validate_presence_of
(
:query
)
}
it
{
is_expected
.
to
validate_presence_of
(
:group
)
}
it_behaves_like
'Unique enum values'
describe
'common metrics'
do
using
RSpec
::
Parameterized
::
TableSyntax
...
...
spec/models/push_event_payload_spec.rb
View file @
dd4a8df4
require
'spec_helper'
describe
PushEventPayload
do
it_behaves_like
'Unique enum values'
describe
'saving payloads'
do
it
'does not allow commit messages longer than 70 characters'
do
event
=
create
(
:push_event
)
...
...
spec/models/resource_label_event_spec.rb
View file @
dd4a8df4
...
...
@@ -7,6 +7,8 @@ RSpec.describe ResourceLabelEvent, type: :model do
let
(
:issue
)
{
create
(
:issue
)
}
let
(
:merge_request
)
{
create
(
:merge_request
)
}
it_behaves_like
'Unique enum values'
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:user
)
}
it
{
is_expected
.
to
belong_to
(
:issue
)
}
...
...
spec/models/user_callout_spec.rb
View file @
dd4a8df4
...
...
@@ -3,6 +3,8 @@ require 'rails_helper'
describe
UserCallout
do
let!
(
:callout
)
{
create
(
:user_callout
)
}
it_behaves_like
'Unique enum values'
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:user
)
}
end
...
...
spec/models/user_spec.rb
View file @
dd4a8df4
...
...
@@ -159,6 +159,8 @@ describe User do
it
{
is_expected
.
to
validate_length_of
(
:bio
).
is_at_most
(
255
)
}
it_behaves_like
'Unique enum values'
it_behaves_like
'an object with email-formated attributes'
,
:email
do
subject
{
build
(
:user
)
}
end
...
...
spec/support/active_record_enum.rb
0 → 100644
View file @
dd4a8df4
# frozen_string_literal: true
shared_examples
'Unique enum values'
do
described_class
.
defined_enums
.
each
do
|
name
,
hash
|
it
"has unique values in
#{
name
}
"
do
expect
(
hash
.
values
).
to
contain_exactly
(
*
hash
.
values
.
uniq
)
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