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
Léo-Paul Géneau
gitlab-ce
Commits
f8391bd7
Commit
f8391bd7
authored
Jul 07, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove validates :key, uniqueness due to new validator covers the case
parent
07c7edd3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
36 deletions
+64
-36
app/models/ci/pipeline_schedule_variable.rb
app/models/ci/pipeline_schedule_variable.rb
+0
-2
spec/controllers/projects/pipeline_schedules_controller_spec.rb
...ontrollers/projects/pipeline_schedules_controller_spec.rb
+64
-34
No files found.
app/models/ci/pipeline_schedule_variable.rb
View file @
f8391bd7
...
@@ -4,7 +4,5 @@ module Ci
...
@@ -4,7 +4,5 @@ module Ci
include
HasVariable
include
HasVariable
belongs_to
:pipeline_schedule
belongs_to
:pipeline_schedule
validates
:key
,
uniqueness:
{
scope: :pipeline_schedule_id
}
end
end
end
end
spec/controllers/projects/pipeline_schedules_controller_spec.rb
View file @
f8391bd7
...
@@ -189,47 +189,77 @@ describe Projects::PipelineSchedulesController do
...
@@ -189,47 +189,77 @@ describe Projects::PipelineSchedulesController do
key:
'CCC'
,
pipeline_schedule:
pipeline_schedule
)
key:
'CCC'
,
pipeline_schedule:
pipeline_schedule
)
end
end
context
'when params include one variable'
do
context
'when adds a new variable'
do
context
'when adds a new variable'
do
let
(
:schedule
)
do
let
(
:schedule
)
do
basic_param
.
merge
({
basic_param
.
merge
({
variables_attributes:
[{
key:
'AAA'
,
value:
'AAA123'
}]
variables_attributes:
[{
key:
'AAA'
,
value:
'AAA123'
}]
})
})
end
end
it
'adds the new variable'
do
it
'adds the new variable'
do
expect
{
go
}.
to
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
1
)
expect
{
go
}.
to
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
1
)
pipeline_schedule
.
reload
pipeline_schedule
.
reload
expect
(
pipeline_schedule
.
variables
.
last
.
key
).
to
eq
(
'AAA'
)
expect
(
pipeline_schedule
.
variables
.
last
.
key
).
to
eq
(
'AAA'
)
end
end
end
context
'when adds a new duplicated variable'
do
let
(
:schedule
)
do
basic_param
.
merge
({
variables_attributes:
[{
key:
'CCC'
,
value:
'AAA123'
}]
})
end
it
'returns an error'
do
expect
{
go
}.
not_to
change
{
Ci
::
PipelineScheduleVariable
.
count
}
pipeline_schedule
.
reload
expect
(
assigns
(
:schedule
).
errors
[
'variables'
]).
not_to
be_empty
end
end
end
context
'when updates a variable'
do
context
'when updates a variable'
do
let
(
:schedule
)
do
let
(
:schedule
)
do
basic_param
.
merge
({
basic_param
.
merge
({
variables_attributes:
[{
id:
pipeline_schedule_variable
.
id
,
value:
'new_value'
}]
variables_attributes:
[{
id:
pipeline_schedule_variable
.
id
,
value:
'new_value'
}]
})
})
end
end
it
'updates the variable'
do
it
'updates the variable'
do
expect
{
go
}.
not_to
change
{
Ci
::
PipelineScheduleVariable
.
count
}
expect
{
go
}.
not_to
change
{
Ci
::
PipelineScheduleVariable
.
count
}
pipeline_schedule_variable
.
reload
pipeline_schedule_variable
.
reload
expect
(
pipeline_schedule_variable
.
value
).
to
eq
(
'new_value'
)
expect
(
pipeline_schedule_variable
.
value
).
to
eq
(
'new_value'
)
end
end
end
end
context
'when deletes a variable'
do
context
'when deletes a variable'
do
let
(
:schedule
)
do
let
(
:schedule
)
do
basic_param
.
merge
({
basic_param
.
merge
({
variables_attributes:
[{
id:
pipeline_schedule_variable
.
id
,
_destroy:
true
}]
variables_attributes:
[{
id:
pipeline_schedule_variable
.
id
,
_destroy:
true
}]
})
})
end
end
it
'delete the existsed variable'
do
it
'delete the existsed variable'
do
expect
{
go
}.
to
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
-
1
)
expect
{
go
}.
to
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
-
1
)
end
end
end
context
'when deletes and creates a same key simultaneously'
do
let
(
:schedule
)
do
basic_param
.
merge
({
variables_attributes:
[{
id:
pipeline_schedule_variable
.
id
,
_destroy:
true
},
{
key:
'CCC'
,
value:
'CCC123'
}]
})
end
it
'updates the variable'
do
expect
{
go
}.
not_to
change
{
Ci
::
PipelineScheduleVariable
.
count
}
pipeline_schedule
.
reload
expect
(
pipeline_schedule
.
variables
.
last
.
key
).
to
eq
(
'CCC'
)
expect
(
pipeline_schedule
.
variables
.
last
.
value
).
to
eq
(
'CCC123'
)
end
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