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
c8eb2a91
Commit
c8eb2a91
authored
Nov 06, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix spec. Revert update check.
parent
9b58b8e3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
6 deletions
+24
-6
jobs.rb
lib/api/jobs.rb
+1
-0
builds.rb
lib/api/v3/builds.rb
+1
-0
build_spec.rb
spec/models/ci/build_spec.rb
+17
-0
build_policy_spec.rb
spec/policies/ci/build_policy_spec.rb
+5
-6
No files found.
lib/api/jobs.rb
View file @
c8eb2a91
...
...
@@ -136,6 +136,7 @@ module API
authorize_update_builds!
build
=
find_build!
(
params
[
:job_id
])
authorize!
(
:update_build
,
build
)
authorize!
(
:erase_build
,
build
)
return
forbidden!
(
'Job is not erasable!'
)
unless
build
.
erasable?
...
...
lib/api/v3/builds.rb
View file @
c8eb2a91
...
...
@@ -169,6 +169,7 @@ module API
authorize_update_builds!
build
=
get_build!
(
params
[
:build_id
])
authorize!
(
:update_build
,
build
)
authorize!
(
:erase_build
,
build
)
return
forbidden!
(
'Build is not erasable!'
)
unless
build
.
erasable?
...
...
spec/models/ci/build_spec.rb
View file @
c8eb2a91
...
...
@@ -270,6 +270,23 @@ describe Ci::Build do
end
end
describe
'#owned_by?'
do
subject
{
build
.
owned_by?
(
user
)
}
context
'when user is owner'
do
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
user:
user
)
}
it
{
is_expected
.
to
be_truthy
}
end
context
'when user is not owner'
do
let
(
:another_user
)
{
create
(
:user
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
user:
another_user
)
}
it
{
is_expected
.
to
be_falsy
}
end
end
describe
'#detailed_status'
do
it
'returns a detailed status'
do
expect
(
build
.
detailed_status
(
user
))
...
...
spec/policies/ci/build_policy_spec.rb
View file @
c8eb2a91
...
...
@@ -151,10 +151,9 @@ describe Ci::BuildPolicy do
end
end
# TODO: Finish spec
describe
'rules for erase build'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:
another_user
)
{
create
(
:us
er
)
}
let
(
:
build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
user:
own
er
)
}
context
'when developer created a build'
do
before
do
...
...
@@ -162,13 +161,13 @@ describe Ci::BuildPolicy do
end
context
'when the build was created by the user'
do
let
(
:
build
)
{
create
(
:ci_build
,
user:
user
)
}
let
(
:
owner
)
{
user
}
it
{
expect
(
policy
).
to
be_allowed
:erase_build
}
end
context
'when the build was created by others'
do
let
(
:
build
)
{
create
(
:ci_build
,
user:
another_
user
)
}
let
(
:
owner
)
{
create
(
:
user
)
}
it
{
expect
(
policy
).
to
be_disallowed
:erase_build
}
end
...
...
@@ -180,13 +179,13 @@ describe Ci::BuildPolicy do
end
context
'when the build was created by the user'
do
let
(
:
build
)
{
create
(
:ci_build
,
user:
user
)
}
let
(
:
owner
)
{
user
}
it
{
expect
(
policy
).
to
be_allowed
:erase_build
}
end
context
'when the build was created by others'
do
let
(
:
build
)
{
create
(
:ci_build
,
user:
another_
user
)
}
let
(
:
owner
)
{
create
(
:
user
)
}
it
{
expect
(
policy
).
to
be_allowed
:erase_build
}
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