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
1bfa818a
Commit
1bfa818a
authored
Jul 04, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zj nice catchies 3
parent
2f70f3fa
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
28 deletions
+34
-28
app/controllers/projects/pipeline_schedules_controller.rb
app/controllers/projects/pipeline_schedules_controller.rb
+1
-1
spec/controllers/projects/pipeline_schedules_controller_spec.rb
...ontrollers/projects/pipeline_schedules_controller_spec.rb
+25
-25
spec/features/projects/pipeline_schedules_spec.rb
spec/features/projects/pipeline_schedules_spec.rb
+2
-0
spec/models/ci/pipeline_schedule_spec.rb
spec/models/ci/pipeline_schedule_spec.rb
+1
-1
spec/support/matchers/access_matchers_for_controller.rb
spec/support/matchers/access_matchers_for_controller.rb
+5
-1
No files found.
app/controllers/projects/pipeline_schedules_controller.rb
View file @
1bfa818a
...
@@ -53,7 +53,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
...
@@ -53,7 +53,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
redirect_to
pipeline_schedules_path
(
@project
),
status:
302
redirect_to
pipeline_schedules_path
(
@project
),
status:
302
else
else
redirect_to
pipeline_schedules_path
(
@project
),
redirect_to
pipeline_schedules_path
(
@project
),
status:
302
,
status:
:forbidden
,
alert:
_
(
"Failed to remove the pipeline schedule"
)
alert:
_
(
"Failed to remove the pipeline schedule"
)
end
end
end
end
...
...
spec/controllers/projects/pipeline_schedules_controller_spec.rb
View file @
1bfa818a
...
@@ -72,7 +72,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -72,7 +72,7 @@ describe Projects::PipelineSchedulesController do
end
end
let
(
:basic_param
)
do
let
(
:basic_param
)
do
{
description:
'aaaaaaaa'
,
cron:
'0 4 * * *'
,
cron_timezone:
'UTC'
,
ref:
'master'
,
active:
'1'
}
attributes_for
(
:ci_pipeline_schedule
)
end
end
context
'when variables_attributes is empty'
do
context
'when variables_attributes is empty'
do
...
@@ -100,8 +100,11 @@ describe Projects::PipelineSchedulesController do
...
@@ -100,8 +100,11 @@ describe Projects::PipelineSchedulesController do
.
and
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
1
)
.
and
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
1
)
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
Ci
::
PipelineScheduleVariable
.
last
.
key
).
to
eq
(
"AAA"
)
expect
(
Ci
::
PipelineScheduleVariable
.
last
.
value
).
to
eq
(
"AAA123"
)
Ci
::
PipelineScheduleVariable
.
last
.
tap
do
|
v
|
expect
(
v
.
key
).
to
eq
(
"AAA"
)
expect
(
v
.
value
).
to
eq
(
"AAA123"
)
end
end
end
context
'when the same key has already been persisted'
do
context
'when the same key has already been persisted'
do
...
@@ -143,10 +146,16 @@ describe Projects::PipelineSchedulesController do
...
@@ -143,10 +146,16 @@ describe Projects::PipelineSchedulesController do
.
and
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
2
)
.
and
change
{
Ci
::
PipelineScheduleVariable
.
count
}.
by
(
2
)
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
Ci
::
PipelineScheduleVariable
.
first
.
key
).
to
eq
(
"AAA"
)
expect
(
Ci
::
PipelineScheduleVariable
.
first
.
value
).
to
eq
(
"AAA123"
)
Ci
::
PipelineScheduleVariable
.
first
.
tap
do
|
v
|
expect
(
Ci
::
PipelineScheduleVariable
.
last
.
key
).
to
eq
(
"BBB"
)
expect
(
v
.
key
).
to
eq
(
"AAA"
)
expect
(
Ci
::
PipelineScheduleVariable
.
last
.
value
).
to
eq
(
"BBB123"
)
expect
(
v
.
value
).
to
eq
(
"AAA123"
)
end
Ci
::
PipelineScheduleVariable
.
last
.
tap
do
|
v
|
expect
(
v
.
key
).
to
eq
(
"BBB"
)
expect
(
v
.
value
).
to
eq
(
"BBB123"
)
end
end
end
end
end
...
@@ -168,7 +177,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -168,7 +177,7 @@ describe Projects::PipelineSchedulesController do
end
end
describe
'security'
do
describe
'security'
do
let
(
:schedule
)
{
{
description:
'aaaaaaaa'
,
cron:
'0 4 * * *'
,
cron_timezone:
'UTC'
,
ref:
'master'
,
active:
'1'
}
}
let
(
:schedule
)
{
attributes_for
(
:ci_pipeline_schedule
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
...
@@ -198,7 +207,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -198,7 +207,7 @@ describe Projects::PipelineSchedulesController do
context
'when a pipeline schedule has no variables'
do
context
'when a pipeline schedule has no variables'
do
let
(
:basic_param
)
do
let
(
:basic_param
)
do
{
description:
'updated_desc'
,
cron:
'0 1 * * *'
,
cron_timezone:
'UTC'
,
ref:
'patch-x'
,
active:
'1'
}
{
description:
'updated_desc'
,
cron:
'0 1 * * *'
,
cron_timezone:
'UTC'
,
ref:
'patch-x'
,
active:
true
}
end
end
context
'when params do not include variables'
do
context
'when params do not include variables'
do
...
@@ -209,11 +218,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -209,11 +218,7 @@ describe Projects::PipelineSchedulesController do
pipeline_schedule
.
reload
pipeline_schedule
.
reload
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
pipeline_schedule
.
description
).
to
eq
(
'updated_desc'
)
expect
(
pipeline_schedule
).
to
have_attributes
(
basic_param
)
expect
(
pipeline_schedule
.
cron
).
to
eq
(
'0 1 * * *'
)
expect
(
pipeline_schedule
.
cron_timezone
).
to
eq
(
'UTC'
)
expect
(
pipeline_schedule
.
ref
).
to
eq
(
'patch-x'
)
expect
(
pipeline_schedule
.
active
).
to
eq
(
true
)
expect
(
pipeline_schedule
.
variables
).
to
be_empty
expect
(
pipeline_schedule
.
variables
).
to
be_empty
end
end
end
end
...
@@ -272,7 +277,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -272,7 +277,7 @@ describe Projects::PipelineSchedulesController do
context
'when a pipeline schedule has one variable'
do
context
'when a pipeline schedule has one variable'
do
let
(
:basic_param
)
do
let
(
:basic_param
)
do
{
description:
'updated_desc'
,
cron:
'0 1 * * *'
,
cron_timezone:
'UTC'
,
ref:
'patch-x'
,
active:
'1'
}
{
description:
'updated_desc'
,
cron:
'0 1 * * *'
,
cron_timezone:
'UTC'
,
ref:
'patch-x'
,
active:
true
}
end
end
let!
(
:pipeline_schedule_variable
)
do
let!
(
:pipeline_schedule_variable
)
do
...
@@ -288,12 +293,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -288,12 +293,7 @@ describe Projects::PipelineSchedulesController do
pipeline_schedule
.
reload
pipeline_schedule
.
reload
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
pipeline_schedule
.
description
).
to
eq
(
'updated_desc'
)
expect
(
pipeline_schedule
).
to
have_attributes
(
basic_param
)
expect
(
pipeline_schedule
.
cron
).
to
eq
(
'0 1 * * *'
)
expect
(
pipeline_schedule
.
cron_timezone
).
to
eq
(
'UTC'
)
expect
(
pipeline_schedule
.
ref
).
to
eq
(
'patch-x'
)
expect
(
pipeline_schedule
.
active
).
to
eq
(
true
)
expect
(
pipeline_schedule
.
variables
.
count
).
to
eq
(
1
)
expect
(
pipeline_schedule
.
variables
.
last
.
key
).
to
eq
(
'CCC'
)
expect
(
pipeline_schedule
.
variables
.
last
.
key
).
to
eq
(
'CCC'
)
end
end
end
end
...
@@ -350,7 +350,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -350,7 +350,7 @@ describe Projects::PipelineSchedulesController do
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
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
(
:master
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:developer
).
of
(
project
).
own
(
[
pipeline_schedule
]
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:developer
).
of
(
project
).
own
(
pipeline_schedule
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:reporter
).
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
(
:guest
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:user
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:user
)
}
...
@@ -412,7 +412,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -412,7 +412,7 @@ describe Projects::PipelineSchedulesController do
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
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
(
:master
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:developer
).
of
(
project
).
own
(
[
pipeline_schedule
]
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:developer
).
of
(
project
).
own
(
pipeline_schedule
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:reporter
).
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
(
:guest
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:user
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:user
)
}
...
@@ -430,7 +430,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -430,7 +430,7 @@ describe Projects::PipelineSchedulesController do
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
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
(
:master
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:developer
).
of
(
project
).
own
(
[
pipeline_schedule
]
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:developer
).
of
(
project
).
own
(
pipeline_schedule
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:reporter
).
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
(
:guest
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:user
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:user
)
}
...
@@ -455,7 +455,7 @@ describe Projects::PipelineSchedulesController do
...
@@ -455,7 +455,7 @@ describe Projects::PipelineSchedulesController do
end
end
it
'does not delete the pipeline schedule'
do
it
'does not delete the pipeline schedule'
do
expect
(
response
).
not_to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:not_found
)
end
end
end
end
...
...
spec/features/projects/pipeline_schedules_spec.rb
View file @
1bfa818a
...
@@ -157,6 +157,7 @@ feature 'Pipeline Schedules', :feature, js: true do
...
@@ -157,6 +157,7 @@ feature 'Pipeline Schedules', :feature, js: true do
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
user
).
tap
do
|
pipeline_schedule
|
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
user
).
tap
do
|
pipeline_schedule
|
create
(
:ci_pipeline_schedule_variable
,
key:
'AAA'
,
value:
'AAA123'
,
pipeline_schedule:
pipeline_schedule
)
create
(
:ci_pipeline_schedule_variable
,
key:
'AAA'
,
value:
'AAA123'
,
pipeline_schedule:
pipeline_schedule
)
end
end
visit_pipelines_schedules
visit_pipelines_schedules
find
(
".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']"
).
click
find
(
".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']"
).
click
all
(
'[name="schedule[variables_attributes][][key]"]'
)[
0
].
set
(
'foo'
)
all
(
'[name="schedule[variables_attributes][][key]"]'
)[
0
].
set
(
'foo'
)
...
@@ -178,6 +179,7 @@ feature 'Pipeline Schedules', :feature, js: true do
...
@@ -178,6 +179,7 @@ feature 'Pipeline Schedules', :feature, js: true do
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
user
).
tap
do
|
pipeline_schedule
|
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
user
).
tap
do
|
pipeline_schedule
|
create
(
:ci_pipeline_schedule_variable
,
key:
'AAA'
,
value:
'AAA123'
,
pipeline_schedule:
pipeline_schedule
)
create
(
:ci_pipeline_schedule_variable
,
key:
'AAA'
,
value:
'AAA123'
,
pipeline_schedule:
pipeline_schedule
)
end
end
visit_pipelines_schedules
visit_pipelines_schedules
find
(
".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']"
).
click
find
(
".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']"
).
click
find
(
'.pipeline-variable-list .pipeline-variable-row-remove-button'
).
click
find
(
'.pipeline-variable-list .pipeline-variable-row-remove-button'
).
click
...
...
spec/models/ci/pipeline_schedule_spec.rb
View file @
1bfa818a
...
@@ -120,7 +120,7 @@ describe Ci::PipelineSchedule, models: true do
...
@@ -120,7 +120,7 @@ describe Ci::PipelineSchedule, models: true do
end
end
describe
'#job_variables'
do
describe
'#job_variables'
do
let!
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
,
:nightly
)
}
let!
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
)
}
let!
(
:pipeline_schedule_variables
)
do
let!
(
:pipeline_schedule_variables
)
do
create_list
(
:ci_pipeline_schedule_variable
,
2
,
pipeline_schedule:
pipeline_schedule
)
create_list
(
:ci_pipeline_schedule_variable
,
2
,
pipeline_schedule:
pipeline_schedule
)
...
...
spec/support/matchers/access_matchers_for_controller.rb
View file @
1bfa818a
...
@@ -77,7 +77,7 @@ module AccessMatchersForController
...
@@ -77,7 +77,7 @@ module AccessMatchersForController
@membership
=
membership
@membership
=
membership
end
end
chain
:own
do
|
objects
|
chain
:own
do
|
*
objects
|
@objects
=
objects
@objects
=
objects
end
end
...
@@ -98,6 +98,10 @@ module AccessMatchersForController
...
@@ -98,6 +98,10 @@ module AccessMatchersForController
@membership
=
membership
@membership
=
membership
end
end
chain
:own
do
|*
objects
|
@objects
=
objects
end
description
{
description_for
(
role
,
'denied'
,
EXPECTED_STATUS_CODE_DENIED
,
response
.
status
)
}
description
{
description_for
(
role
,
'denied'
,
EXPECTED_STATUS_CODE_DENIED
,
response
.
status
)
}
supports_block_expectations
supports_block_expectations
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