BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e5d9f4a3
Unverified
Commit
e5d9f4a3
authored
Feb 13, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for VariableDuplicates validator
parent
c047fb86
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
variable_duplicates_validator_spec.rb
spec/validators/variable_duplicates_validator_spec.rb
+67
-0
No files found.
spec/validators/variable_duplicates_validator_spec.rb
0 → 100644
View file @
e5d9f4a3
require
'spec_helper'
describe
VariableDuplicatesValidator
do
let
(
:validator
)
{
described_class
.
new
(
attributes:
[
:variables
],
**
options
)
}
describe
'#validate_each'
do
let
(
:project
)
{
build
(
:project
)
}
subject
{
validator
.
validate_each
(
project
,
:variables
,
project
.
variables
)
}
context
'with no scope'
do
let
(
:options
)
{
{}
}
let
(
:variables
)
{
build_list
(
:ci_variable
,
2
,
project:
project
)
}
before
do
project
.
variables
<<
variables
end
it
'does not have any errors'
do
subject
expect
(
project
.
errors
.
empty?
).
to
be
true
end
context
'with duplicates'
do
before
do
project
.
variables
.
build
(
key:
variables
.
first
.
key
,
value:
'dummy_value'
)
end
it
'has a duplicate key error'
do
subject
expect
(
project
.
errors
[
:variables
]).
to
include
(
"Duplicate variables:
#{
project
.
variables
.
last
.
key
}
"
)
end
end
end
context
'with a scope attribute'
do
let
(
:options
)
{
{
scope: :environment_scope
}
}
let
(
:first_variable
)
{
build
(
:ci_variable
,
key:
'test_key'
,
environment_scope:
'*'
,
project:
project
)
}
let
(
:second_variable
)
{
build
(
:ci_variable
,
key:
'test_key'
,
environment_scope:
'prod'
,
project:
project
)
}
before
do
project
.
variables
<<
first_variable
project
.
variables
<<
second_variable
end
it
'does not have any errors'
do
subject
expect
(
project
.
errors
.
empty?
).
to
be
true
end
context
'with duplicates'
do
before
do
project
.
variables
.
build
(
key:
second_variable
.
key
,
value:
'dummy_value'
,
environment_scope:
second_variable
.
environment_scope
)
end
it
'has a duplicate key error'
do
subject
expect
(
project
.
errors
[
:variables
]).
to
include
(
"Duplicate variables:
#{
project
.
variables
.
last
.
key
}
"
)
end
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