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
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
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
6 deletions
+24
-6
lib/api/jobs.rb
lib/api/jobs.rb
+1
-0
lib/api/v3/builds.rb
lib/api/v3/builds.rb
+1
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+17
-0
spec/policies/ci/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
...
@@ -136,6 +136,7 @@ module API
authorize_update_builds!
authorize_update_builds!
build
=
find_build!
(
params
[
:job_id
])
build
=
find_build!
(
params
[
:job_id
])
authorize!
(
:update_build
,
build
)
authorize!
(
:erase_build
,
build
)
authorize!
(
:erase_build
,
build
)
return
forbidden!
(
'Job is not erasable!'
)
unless
build
.
erasable?
return
forbidden!
(
'Job is not erasable!'
)
unless
build
.
erasable?
...
...
lib/api/v3/builds.rb
View file @
c8eb2a91
...
@@ -169,6 +169,7 @@ module API
...
@@ -169,6 +169,7 @@ module API
authorize_update_builds!
authorize_update_builds!
build
=
get_build!
(
params
[
:build_id
])
build
=
get_build!
(
params
[
:build_id
])
authorize!
(
:update_build
,
build
)
authorize!
(
:erase_build
,
build
)
authorize!
(
:erase_build
,
build
)
return
forbidden!
(
'Build is not erasable!'
)
unless
build
.
erasable?
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
...
@@ -270,6 +270,23 @@ describe Ci::Build do
end
end
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
describe
'#detailed_status'
do
it
'returns a detailed status'
do
it
'returns a detailed status'
do
expect
(
build
.
detailed_status
(
user
))
expect
(
build
.
detailed_status
(
user
))
...
...
spec/policies/ci/build_policy_spec.rb
View file @
c8eb2a91
...
@@ -151,10 +151,9 @@ describe Ci::BuildPolicy do
...
@@ -151,10 +151,9 @@ describe Ci::BuildPolicy do
end
end
end
end
# TODO: Finish spec
describe
'rules for erase build'
do
describe
'rules for erase build'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
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
context
'when developer created a build'
do
before
do
before
do
...
@@ -162,13 +161,13 @@ describe Ci::BuildPolicy do
...
@@ -162,13 +161,13 @@ describe Ci::BuildPolicy do
end
end
context
'when the build was created by the user'
do
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
}
it
{
expect
(
policy
).
to
be_allowed
:erase_build
}
end
end
context
'when the build was created by others'
do
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
}
it
{
expect
(
policy
).
to
be_disallowed
:erase_build
}
end
end
...
@@ -180,13 +179,13 @@ describe Ci::BuildPolicy do
...
@@ -180,13 +179,13 @@ describe Ci::BuildPolicy do
end
end
context
'when the build was created by the user'
do
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
}
it
{
expect
(
policy
).
to
be_allowed
:erase_build
}
end
end
context
'when the build was created by others'
do
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
}
it
{
expect
(
policy
).
to
be_allowed
:erase_build
}
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