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
c1db5b91
Commit
c1db5b91
authored
Dec 08, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some detailed statuses specs related to abilities
parent
7d883994
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
49 additions
and
18 deletions
+49
-18
app/models/ability.rb
app/models/ability.rb
+6
-0
lib/gitlab/ci/status/core.rb
lib/gitlab/ci/status/core.rb
+1
-0
lib/gitlab/ci/status/stage/common.rb
lib/gitlab/ci/status/stage/common.rb
+1
-1
spec/lib/gitlab/ci/status/canceled_spec.rb
spec/lib/gitlab/ci/status/canceled_spec.rb
+0
-4
spec/lib/gitlab/ci/status/extended_spec.rb
spec/lib/gitlab/ci/status/extended_spec.rb
+1
-1
spec/lib/gitlab/ci/status/pipeline/common_spec.rb
spec/lib/gitlab/ci/status/pipeline/common_spec.rb
+6
-1
spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
+5
-0
spec/lib/gitlab/ci/status/pipeline/success_with_warnings_spec.rb
...b/gitlab/ci/status/pipeline/success_with_warnings_spec.rb
+5
-5
spec/lib/gitlab/ci/status/stage/common_spec.rb
spec/lib/gitlab/ci/status/stage/common_spec.rb
+18
-5
spec/lib/gitlab/ci/status/stage/factory_spec.rb
spec/lib/gitlab/ci/status/stage/factory_spec.rb
+6
-1
No files found.
app/models/ability.rb
View file @
c1db5b91
class
Ability
module
Allowable
def
can?
(
user
,
action
,
subject
)
Ability
.
allowed?
(
user
,
action
,
subject
)
end
end
class
<<
self
# Given a list of users and a project this method returns the users that can
# read the given project.
...
...
lib/gitlab/ci/status/core.rb
View file @
c1db5b91
...
...
@@ -5,6 +5,7 @@ module Gitlab
#
class
Core
include
Gitlab
::
Routing
.
url_helpers
include
Ability
::
Allowable
attr_reader
:subject
,
:user
...
...
lib/gitlab/ci/status/stage/common.rb
View file @
c1db5b91
...
...
@@ -4,7 +4,7 @@ module Gitlab
module
Stage
module
Common
def
has_details?
can?
(
user
,
:read_pipeline
,
subject
)
can?
(
user
,
:read_pipeline
,
subject
.
pipeline
)
end
def
details_path
...
...
spec/lib/gitlab/ci/status/canceled_spec.rb
View file @
c1db5b91
...
...
@@ -16,8 +16,4 @@ describe Gitlab::Ci::Status::Canceled do
describe
'#icon'
do
it
{
expect
(
subject
.
icon
).
to
eq
'icon_status_canceled'
}
end
describe
'#title'
do
it
{
expect
(
subject
.
title
).
to
eq
'Double: canceled'
}
end
end
spec/lib/gitlab/ci/status/extended_spec.rb
View file @
c1db5b91
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Extended
do
subject
do
Class
.
new
.
extend
(
described_class
)
Class
.
new
.
include
(
described_class
)
end
it
'requires subclass to implement matcher'
do
...
...
spec/lib/gitlab/ci/status/pipeline/common_spec.rb
View file @
c1db5b91
...
...
@@ -2,7 +2,8 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Pipeline
::
Common
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
subject
do
Class
.
new
(
Gitlab
::
Ci
::
Status
::
Core
)
...
...
@@ -10,6 +11,10 @@ describe Gitlab::Ci::Status::Pipeline::Common do
.
extend
(
described_class
)
end
before
do
project
.
team
<<
[
user
,
:developer
]
end
it
'does not have action'
do
expect
(
subject
).
not_to
have_action
end
...
...
spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
View file @
c1db5b91
...
...
@@ -2,6 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Pipeline
::
Factory
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
pipeline
.
project
}
subject
do
described_class
.
new
(
pipeline
,
user
)
...
...
@@ -11,6 +12,10 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
subject
.
fabricate!
end
before
do
project
.
team
<<
[
user
,
:developer
]
end
context
'when pipeline has a core status'
do
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
core_status
|
context
"when core status is
#{
core_status
}
"
do
...
...
spec/lib/gitlab/ci/status/pipeline/success_with_warnings_spec.rb
View file @
c1db5b91
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Pipeline
::
SuccessWithWarnings
do
subject
do
described_class
.
new
(
double
(
'status'
)
,
double
(
'user'
)
)
described_class
.
new
(
double
(
'status'
))
end
describe
'#test'
do
...
...
@@ -29,13 +29,13 @@ describe Gitlab::Ci::Status::Pipeline::SuccessWithWarnings do
end
it
'is a correct match'
do
expect
(
described_class
.
matches?
(
pipeline
)).
to
eq
true
expect
(
described_class
.
matches?
(
pipeline
,
double
)).
to
eq
true
end
end
context
'when pipeline does not have warnings'
do
it
'does not match'
do
expect
(
described_class
.
matches?
(
pipeline
)).
to
eq
false
expect
(
described_class
.
matches?
(
pipeline
,
double
)).
to
eq
false
end
end
end
...
...
@@ -51,13 +51,13 @@ describe Gitlab::Ci::Status::Pipeline::SuccessWithWarnings do
end
it
'does not match'
do
expect
(
described_class
.
matches?
(
pipeline
)).
to
eq
false
expect
(
described_class
.
matches?
(
pipeline
,
double
)).
to
eq
false
end
end
context
'when pipeline does not have warnings'
do
it
'does not match'
do
expect
(
described_class
.
matches?
(
pipeline
)).
to
eq
false
expect
(
described_class
.
matches?
(
pipeline
,
double
)).
to
eq
false
end
end
end
...
...
spec/lib/gitlab/ci/status/stage/common_spec.rb
View file @
c1db5b91
...
...
@@ -2,7 +2,8 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Stage
::
Common
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let
(
:stage
)
do
build
(
:ci_stage
,
pipeline:
pipeline
,
name:
'test'
)
...
...
@@ -17,14 +18,26 @@ describe Gitlab::Ci::Status::Stage::Common do
expect
(
subject
).
not_to
have_action
end
it
'has details'
do
expect
(
subject
).
to
have_details
end
it
'links to the pipeline details page'
do
expect
(
subject
.
details_path
)
.
to
include
"pipelines/
#{
pipeline
.
id
}
"
expect
(
subject
.
details_path
)
.
to
include
"#
#{
stage
.
name
}
"
end
context
'when user has permission to read pipeline'
do
before
do
project
.
team
<<
[
user
,
:master
]
end
it
'has details'
do
expect
(
subject
).
to
have_details
end
end
context
'when user does not have permission to read pipeline'
do
it
'does not have details'
do
expect
(
subject
).
not_to
have_details
end
end
end
spec/lib/gitlab/ci/status/stage/factory_spec.rb
View file @
c1db5b91
...
...
@@ -2,7 +2,8 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Stage
::
Factory
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let
(
:stage
)
do
build
(
:ci_stage
,
pipeline:
pipeline
,
name:
'test'
)
...
...
@@ -16,6 +17,10 @@ describe Gitlab::Ci::Status::Stage::Factory do
subject
.
fabricate!
end
before
do
project
.
team
<<
[
user
,
:developer
]
end
context
'when stage has a core status'
do
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
core_status
|
context
"when core status is
#{
core_status
}
"
do
...
...
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