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
749f05ae
Commit
749f05ae
authored
Jun 29, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix StaticAnlysys
parent
e1ba0058
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
109 deletions
+59
-109
db/migrate/20170620064728_create_ci_pipeline_schedule_variables.rb
...e/20170620064728_create_ci_pipeline_schedule_variables.rb
+1
-1
spec/controllers/projects/pipeline_schedules_controller_spec.rb
...ontrollers/projects/pipeline_schedules_controller_spec.rb
+58
-108
No files found.
db/migrate/20170620064728_create_ci_pipeline_schedule_variables.rb
View file @
749f05ae
...
@@ -10,7 +10,7 @@ class CreateCiPipelineScheduleVariables < ActiveRecord::Migration
...
@@ -10,7 +10,7 @@ class CreateCiPipelineScheduleVariables < ActiveRecord::Migration
t
.
string
:encrypted_value_iv
t
.
string
:encrypted_value_iv
t
.
integer
:pipeline_schedule_id
,
null:
false
t
.
integer
:pipeline_schedule_id
,
null:
false
t
.
timestamps
null:
fals
e
t
.
timestamps
_with_timezone
null:
tru
e
end
end
add_index
:ci_pipeline_schedule_variables
,
add_index
:ci_pipeline_schedule_variables
,
...
...
spec/controllers/projects/pipeline_schedules_controller_spec.rb
View file @
749f05ae
...
@@ -71,7 +71,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -71,7 +71,7 @@ describe Projects::PipelineSchedulesController do
let
(
:schedule
)
{
basic_param
}
let
(
:schedule
)
{
basic_param
}
it
'creates a new schedule'
do
it
'creates a new schedule'
do
expect
{
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
schedule:
schedule
}
expect
{
go
}
.
to
change
{
Ci
::
PipelineSchedule
.
count
}.
by
(
1
)
.
to
change
{
Ci
::
PipelineSchedule
.
count
}.
by
(
1
)
.
and
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
0
)
.
and
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
0
)
...
@@ -82,12 +82,12 @@ describe Projects::PipelineSchedulesController do
...
@@ -82,12 +82,12 @@ describe Projects::PipelineSchedulesController do
context
'when variables_attributes has one variable'
do
context
'when variables_attributes has one 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
'creates a new schedule'
do
it
'creates a new schedule'
do
expect
{
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
schedule:
schedule
}
expect
{
go
}
.
to
change
{
Ci
::
PipelineSchedule
.
count
}.
by
(
1
)
.
to
change
{
Ci
::
PipelineSchedule
.
count
}.
by
(
1
)
.
and
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
1
)
.
and
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
1
)
...
@@ -98,7 +98,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -98,7 +98,7 @@ describe Projects::PipelineSchedulesController do
context
'when the same key has already been persisted'
do
context
'when the same key has already been persisted'
do
it
'returns an error that the key of variable is invaild'
do
it
'returns an error that the key of variable is invaild'
do
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
schedule:
schedule
go
pipeline_schedule_variable
=
build
(
:ci_pipeline_schedule_variable
,
key:
'AAA'
,
pipeline_schedule:
assigns
(
:schedule
))
pipeline_schedule_variable
=
build
(
:ci_pipeline_schedule_variable
,
key:
'AAA'
,
pipeline_schedule:
assigns
(
:schedule
))
expect
(
pipeline_schedule_variable
).
to
be_invalid
expect
(
pipeline_schedule_variable
).
to
be_invalid
...
@@ -109,12 +109,12 @@ describe Projects::PipelineSchedulesController do
...
@@ -109,12 +109,12 @@ describe Projects::PipelineSchedulesController do
context
'when variables_attributes has one variable and key is empty'
do
context
'when variables_attributes has one variable and key is empty'
do
let
(
:schedule
)
do
let
(
:schedule
)
do
basic_param
.
merge
({
basic_param
.
merge
({
variables_attributes:
[
{
key:
''
,
value:
'AAA123'
}
]
variables_attributes:
[
{
key:
''
,
value:
'AAA123'
}
]
})
})
end
end
it
'returns an error that the key of variable is invaild'
do
it
'returns an error that the key of variable is invaild'
do
expect
{
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
schedule:
schedule
}
expect
{
go
}
.
to
change
{
Ci
::
PipelineSchedule
.
count
}.
by
(
0
)
.
to
change
{
Ci
::
PipelineSchedule
.
count
}.
by
(
0
)
.
and
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
0
)
.
and
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
0
)
...
@@ -125,12 +125,12 @@ describe Projects::PipelineSchedulesController do
...
@@ -125,12 +125,12 @@ describe Projects::PipelineSchedulesController do
context
'when variables_attributes has two variables and unique'
do
context
'when variables_attributes has two variables and unique'
do
let
(
:schedule
)
do
let
(
:schedule
)
do
basic_param
.
merge
({
basic_param
.
merge
({
variables_attributes:
[
{
key:
'AAA'
,
value:
'AAA123'
},
{
key:
'BBB'
,
value:
'BBB123'
}
]
variables_attributes:
[
{
key:
'AAA'
,
value:
'AAA123'
},
{
key:
'BBB'
,
value:
'BBB123'
}
]
})
})
end
end
it
'creates a new schedule'
do
it
'creates a new schedule'
do
expect
{
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
schedule:
schedule
}
expect
{
go
}
.
to
change
{
Ci
::
PipelineSchedule
.
count
}.
by
(
1
)
.
to
change
{
Ci
::
PipelineSchedule
.
count
}.
by
(
1
)
.
and
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
2
)
.
and
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
2
)
...
@@ -146,39 +146,42 @@ describe Projects::PipelineSchedulesController do
...
@@ -146,39 +146,42 @@ describe Projects::PipelineSchedulesController do
# context 'when variables_attributes has two variables and duplicted' do
# context 'when variables_attributes has two variables and duplicted' do
# let(:schedule) do
# let(:schedule) do
# basic_param.merge({
# basic_param.merge({
# variables_attributes: [
{ key: 'AAA', value: 'AAA123' }, { key: 'AAA', value: 'BBB123' }
]
# variables_attributes: [
{ key: 'AAA', value: 'AAA123' }, { key: 'AAA', value: 'BBB123' }
]
# })
# })
# end
# end
# it 'returns an error that the keys of variable are duplicated' do
# it 'returns an error that the keys of variable are duplicated' do
# expect {
post :create, namespace_id: project.namespace.to_param, project_id: project, schedule: schedule
}
# expect {
go
}
# .to change { Ci::PipelineSchedule.count }.by(0)
# .to change { Ci::PipelineSchedule.count }.by(0)
# .and change { Ci::PipelineScheduleVariable.count }.by(0)
# .and change { Ci::PipelineScheduleVariable.count }.by(0)
# expect(assigns(:schedule).errors['variables.key']).not_to be_empty
# expect(assigns(:schedule).errors['variables.key']).not_to be_empty
# end
# end
# end
# end
def
go
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
schedule:
schedule
end
end
end
describe
'security'
do
describe
'security'
do
let
(
:action
)
do
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
proc
do
|
user
|
it
{
expect
{
go
}.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:master
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:developer
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:reporter
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:guest
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:user
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:external
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:visitor
)
}
def
go
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
project_id:
project
,
schedule:
{
description:
'aaaaaaaa'
,
cron:
'0 4 * * *'
,
schedule:
{
description:
'aaaaaaaa'
,
cron:
'0 4 * * *'
,
cron_timezone:
'UTC'
,
ref:
'master'
,
active:
'1'
}
cron_timezone:
'UTC'
,
ref:
'master'
,
end
active:
'1'
}
end
end
specify
{
expect
(
action
).
to
be_allowed_for
(
:admin
)
}
specify
{
expect
(
action
).
to
be_allowed_for
(
:owner
).
of
(
project
)
}
specify
{
expect
(
action
).
to
be_allowed_for
(
:master
).
of
(
project
)
}
specify
{
expect
(
action
).
to
be_allowed_for
(
:developer
).
of
(
project
)
}
specify
{
expect
(
action
).
to
be_denied_for
(
:reporter
).
of
(
project
)
}
specify
{
expect
(
action
).
to
be_denied_for
(
:guest
).
of
(
project
)
}
specify
{
expect
(
action
).
to
be_denied_for
(
:user
)
}
specify
{
expect
(
action
).
to
be_denied_for
(
:external
)
}
specify
{
expect
(
action
).
to
be_denied_for
(
:visitor
)
}
end
end
end
end
...
@@ -202,8 +205,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -202,8 +205,7 @@ describe Projects::PipelineSchedulesController do
let
(
:schedule
)
{
basic_param
}
let
(
:schedule
)
{
basic_param
}
it
'updates only scheduled pipeline attributes'
do
it
'updates only scheduled pipeline attributes'
do
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
go
project_id:
project
,
id:
pipeline_schedule
,
schedule:
schedule
pipeline_schedule
.
reload
pipeline_schedule
.
reload
...
@@ -220,15 +222,12 @@ describe Projects::PipelineSchedulesController do
...
@@ -220,15 +222,12 @@ describe Projects::PipelineSchedulesController do
context
'when params include one variable'
do
context
'when params include one 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
'inserts new variable to the pipeline schedule'
do
it
'inserts new variable to the pipeline schedule'
do
expect
do
expect
{
go
}.
to
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
1
)
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
,
schedule:
schedule
end
.
to
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
1
)
pipeline_schedule
.
reload
pipeline_schedule
.
reload
...
@@ -241,15 +240,12 @@ describe Projects::PipelineSchedulesController do
...
@@ -241,15 +240,12 @@ describe Projects::PipelineSchedulesController do
context
'when params include two unique variables'
do
context
'when params include two unique variables'
do
let
(
:schedule
)
do
let
(
:schedule
)
do
basic_param
.
merge
({
basic_param
.
merge
({
variables_attributes:
[
{
key:
'AAA'
,
value:
'AAA123'
},
{
key:
'BBB'
,
value:
'BBB123'
}
]
variables_attributes:
[
{
key:
'AAA'
,
value:
'AAA123'
},
{
key:
'BBB'
,
value:
'BBB123'
}
]
})
})
end
end
it
'inserts two new variables to the pipeline schedule'
do
it
'inserts two new variables to the pipeline schedule'
do
expect
do
expect
{
go
}.
to
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
2
)
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
,
schedule:
schedule
end
.
to
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
2
)
pipeline_schedule
.
reload
pipeline_schedule
.
reload
...
@@ -265,7 +261,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -265,7 +261,7 @@ describe Projects::PipelineSchedulesController do
# context 'when params include two duplicated variables' do
# context 'when params include two duplicated variables' do
# let(:schedule) do
# let(:schedule) do
# basic_param.merge({
# basic_param.merge({
# variables_attributes: [
{ key: 'AAA', value: 'AAA123' }, { key: 'AAA', value: 'BBB123' }
]
# variables_attributes: [
{ key: 'AAA', value: 'AAA123' }, { key: 'AAA', value: 'BBB123' }
]
# })
# })
# end
# end
...
@@ -292,8 +288,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -292,8 +288,7 @@ describe Projects::PipelineSchedulesController do
let
(
:schedule
)
{
basic_param
}
let
(
:schedule
)
{
basic_param
}
it
'updates only scheduled pipeline attributes'
do
it
'updates only scheduled pipeline attributes'
do
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
go
project_id:
project
,
id:
pipeline_schedule
,
schedule:
schedule
pipeline_schedule
.
reload
pipeline_schedule
.
reload
...
@@ -317,10 +312,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -317,10 +312,7 @@ describe Projects::PipelineSchedulesController do
end
end
it
'adds the new variable'
do
it
'adds the new variable'
do
expect
do
expect
{
go
}.
to
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
1
)
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
,
schedule:
schedule
end
.
to
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
1
)
expect
(
pipeline_schedule
.
variables
.
last
.
key
).
to
eq
(
'AAA'
)
expect
(
pipeline_schedule
.
variables
.
last
.
key
).
to
eq
(
'AAA'
)
end
end
...
@@ -334,10 +326,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -334,10 +326,7 @@ describe Projects::PipelineSchedulesController do
end
end
it
'updates the variable'
do
it
'updates the variable'
do
expect
do
expect
{
go
}.
not_to
change
{
Ci
::
PipelineScheduleVariable
.
count
}
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
,
schedule:
schedule
end
.
not_to
change
{
Ci
::
PipelineScheduleVariable
.
count
}
pipeline_schedule_variable
.
reload
pipeline_schedule_variable
.
reload
...
@@ -353,14 +342,17 @@ describe Projects::PipelineSchedulesController do
...
@@ -353,14 +342,17 @@ describe Projects::PipelineSchedulesController do
end
end
it
'delete the existsed variable'
do
it
'delete the existsed variable'
do
expect
do
expect
{
go
}.
to
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
-
1
)
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
,
schedule:
schedule
end
.
to
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
-
1
)
end
end
end
end
end
end
end
end
def
go
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
,
schedule:
schedule
end
end
end
describe
'security'
do
describe
'security'
do
...
@@ -373,39 +365,15 @@ describe Projects::PipelineSchedulesController do
...
@@ -373,39 +365,15 @@ describe Projects::PipelineSchedulesController do
end
end
context
'when the developer updates'
do
context
'when the developer updates'
do
let
(
:action
)
do
it
{
expect
{
go
}.
to
be_allowed_for
(
developer_1
)
}
proc
do
|
user
|
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
,
schedule:
{
description:
'updated_desc'
}
end
end
specify
{
expect
(
action
).
to
be_allowed_for
(
developer_1
)
}
end
end
context
'when another developer updates'
do
context
'when another developer updates'
do
let
(
:action
)
do
it
{
expect
{
go
}.
to
be_denied_for
(
:developer
).
of
(
project
)
}
proc
do
|
user
|
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
,
schedule:
{
description:
'updated_desc'
}
end
end
specify
{
expect
(
action
).
to
be_denied_for
(
:developer
).
of
(
project
)
}
end
end
context
'when a master updates'
do
context
'when a master updates'
do
let
(
:action
)
do
it
{
expect
{
go
}.
to
be_allowed_for
(
:master
).
of
(
project
)
}
proc
do
|
user
|
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
,
schedule:
{
description:
'updated_desc'
}
end
end
specify
{
expect
(
action
).
to
be_allowed_for
(
:master
).
of
(
project
)
}
end
end
end
end
...
@@ -418,44 +386,26 @@ describe Projects::PipelineSchedulesController do
...
@@ -418,44 +386,26 @@ describe Projects::PipelineSchedulesController do
end
end
context
'when the master updates'
do
context
'when the master updates'
do
let
(
:action
)
do
it
{
expect
{
go
}.
to
be_allowed_for
(
master_1
)
}
proc
do
|
user
|
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
,
schedule:
{
description:
'updated_desc'
}
end
end
end
specify
{
expect
(
action
).
to
be_allowed_for
(
master_1
)
}
context
'when other masters updates'
do
it
{
expect
{
go
}.
to
be_allowed_for
(
:master
).
of
(
project
)
}
end
end
context
'when other masters updates'
do
context
'when a developer updates'
do
let
(
:action
)
do
it
{
expect
{
go
}.
to
be_denied_for
(
:developer
).
of
(
project
)
}
proc
do
|
user
|
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
,
schedule:
{
description:
'updated_desc'
}
end
end
end
end
specify
{
expect
(
action
).
to
be_allowed_for
(
:master
).
of
(
project
)
}
end
end
context
'when a developer updates'
do
def
go
let
(
:action
)
do
proc
do
|
user
|
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
,
project_id:
project
,
id:
pipeline_schedule
,
schedule:
{
description:
'updated_desc'
}
schedule:
{
description:
'updated_desc'
}
end
end
end
end
specify
{
expect
(
action
).
to
be_denied_for
(
:developer
).
of
(
project
)
}
end
end
end
end
describe
'GET edit'
do
describe
'GET edit'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
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