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
d8fb903e
Commit
d8fb903e
authored
Nov 07, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve spec
parent
d89c1890
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
29 deletions
+71
-29
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+1
-1
spec/policies/ci/build_policy_spec.rb
spec/policies/ci/build_policy_spec.rb
+27
-9
spec/requests/api/jobs_spec.rb
spec/requests/api/jobs_spec.rb
+43
-19
No files found.
spec/controllers/projects/jobs_controller_spec.rb
View file @
d8fb903e
...
@@ -422,7 +422,7 @@ describe Projects::JobsController do
...
@@ -422,7 +422,7 @@ describe Projects::JobsController do
let
(
:triggered_by
)
{
create
(
:user
)
}
let
(
:triggered_by
)
{
create
(
:user
)
}
it
'does not have successful status'
do
it
'does not have successful status'
do
expect
(
response
).
to
have_gitlab_http_status
(
:not_
found
)
expect
(
response
).
not_to
have_gitlab_http_status
(
:
found
)
end
end
end
end
end
end
...
...
spec/policies/ci/build_policy_spec.rb
View file @
d8fb903e
...
@@ -152,7 +152,7 @@ describe Ci::BuildPolicy do
...
@@ -152,7 +152,7 @@ describe Ci::BuildPolicy do
end
end
describe
'rules for erase build'
do
describe
'rules for erase build'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
ref:
'some-ref'
,
user:
owner
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
ref:
'some-ref'
,
user:
owner
)
}
context
'when a developer erases a build'
do
context
'when a developer erases a build'
do
...
@@ -162,7 +162,7 @@ describe Ci::BuildPolicy do
...
@@ -162,7 +162,7 @@ describe Ci::BuildPolicy do
context
'when developers can push to the branch'
do
context
'when developers can push to the branch'
do
before
do
before
do
create
(
:protected_branch
,
:developers_can_
merge
,
create
(
:protected_branch
,
:developers_can_
push
,
name:
build
.
ref
,
project:
project
)
name:
build
.
ref
,
project:
project
)
end
end
...
@@ -183,7 +183,7 @@ describe Ci::BuildPolicy do
...
@@ -183,7 +183,7 @@ describe Ci::BuildPolicy do
let
(
:owner
)
{
user
}
let
(
:owner
)
{
user
}
before
do
before
do
create
(
:protected_branch
,
:no_one_can_push
,
create
(
:protected_branch
,
:no_one_can_push
,
:no_one_can_merge
,
name:
build
.
ref
,
project:
project
)
name:
build
.
ref
,
project:
project
)
end
end
...
@@ -196,6 +196,12 @@ describe Ci::BuildPolicy do
...
@@ -196,6 +196,12 @@ describe Ci::BuildPolicy do
project
.
add_master
(
user
)
project
.
add_master
(
user
)
end
end
context
'when masters can push to the branch'
do
before
do
create
(
:protected_branch
,
:masters_can_push
,
name:
build
.
ref
,
project:
project
)
end
context
'when the build was created by the master'
do
context
'when the build was created by the master'
do
let
(
:owner
)
{
user
}
let
(
:owner
)
{
user
}
...
@@ -208,6 +214,18 @@ describe Ci::BuildPolicy do
...
@@ -208,6 +214,18 @@ describe Ci::BuildPolicy do
it
{
expect
(
policy
).
to
be_allowed
:erase_build
}
it
{
expect
(
policy
).
to
be_allowed
:erase_build
}
end
end
end
end
context
'when no one can push or merge to the branch'
do
let
(
:owner
)
{
user
}
before
do
create
(
:protected_branch
,
:no_one_can_push
,
:no_one_can_merge
,
name:
build
.
ref
,
project:
project
)
end
it
{
expect
(
policy
).
to
be_disallowed
:erase_build
}
end
end
end
end
end
end
end
end
spec/requests/api/jobs_spec.rb
View file @
d8fb903e
...
@@ -500,6 +500,7 @@ describe API::Jobs do
...
@@ -500,6 +500,7 @@ describe API::Jobs do
end
end
describe
'POST /projects/:id/jobs/:job_id/erase'
do
describe
'POST /projects/:id/jobs/:job_id/erase'
do
context
'when a master erases a build'
do
before
do
before
do
project
.
add_master
(
user
)
project
.
add_master
(
user
)
...
@@ -533,6 +534,29 @@ describe API::Jobs do
...
@@ -533,6 +534,29 @@ describe API::Jobs do
end
end
end
end
context
'when a developer erases a build'
do
before
do
project
.
add_developer
(
user
)
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/erase"
,
user
)
end
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
:artifacts
,
:success
,
project:
project
,
pipeline:
pipeline
,
user:
owner
)
}
context
'when the build was created by the developer'
do
let
(
:owner
)
{
user
}
it
{
expect
(
response
).
to
have_gitlab_http_status
(
201
)
}
end
context
'when the build was created by the other'
do
let
(
:owner
)
{
create
(
:user
)
}
it
{
expect
(
response
).
to
have_gitlab_http_status
(
403
)
}
end
end
end
describe
'POST /projects/:id/jobs/:job_id/artifacts/keep'
do
describe
'POST /projects/:id/jobs/:job_id/artifacts/keep'
do
before
do
before
do
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/artifacts/keep"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/artifacts/keep"
,
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