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
Tatuya Kamada
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
class
Ability
module
Allowable
def
can?
(
user
,
action
,
subject
)
Ability
.
allowed?
(
user
,
action
,
subject
)
end
end
class
<<
self
class
<<
self
# Given a list of users and a project this method returns the users that can
# Given a list of users and a project this method returns the users that can
# read the given project.
# read the given project.
...
...
lib/gitlab/ci/status/core.rb
View file @
c1db5b91
...
@@ -5,6 +5,7 @@ module Gitlab
...
@@ -5,6 +5,7 @@ module Gitlab
#
#
class
Core
class
Core
include
Gitlab
::
Routing
.
url_helpers
include
Gitlab
::
Routing
.
url_helpers
include
Ability
::
Allowable
attr_reader
:subject
,
:user
attr_reader
:subject
,
:user
...
...
lib/gitlab/ci/status/stage/common.rb
View file @
c1db5b91
...
@@ -4,7 +4,7 @@ module Gitlab
...
@@ -4,7 +4,7 @@ module Gitlab
module
Stage
module
Stage
module
Common
module
Common
def
has_details?
def
has_details?
can?
(
user
,
:read_pipeline
,
subject
)
can?
(
user
,
:read_pipeline
,
subject
.
pipeline
)
end
end
def
details_path
def
details_path
...
...
spec/lib/gitlab/ci/status/canceled_spec.rb
View file @
c1db5b91
...
@@ -16,8 +16,4 @@ describe Gitlab::Ci::Status::Canceled do
...
@@ -16,8 +16,4 @@ describe Gitlab::Ci::Status::Canceled do
describe
'#icon'
do
describe
'#icon'
do
it
{
expect
(
subject
.
icon
).
to
eq
'icon_status_canceled'
}
it
{
expect
(
subject
.
icon
).
to
eq
'icon_status_canceled'
}
end
end
describe
'#title'
do
it
{
expect
(
subject
.
title
).
to
eq
'Double: canceled'
}
end
end
end
spec/lib/gitlab/ci/status/extended_spec.rb
View file @
c1db5b91
...
@@ -2,7 +2,7 @@ require 'spec_helper'
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Extended
do
describe
Gitlab
::
Ci
::
Status
::
Extended
do
subject
do
subject
do
Class
.
new
.
extend
(
described_class
)
Class
.
new
.
include
(
described_class
)
end
end
it
'requires subclass to implement matcher'
do
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'
...
@@ -2,7 +2,8 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Pipeline
::
Common
do
describe
Gitlab
::
Ci
::
Status
::
Pipeline
::
Common
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
subject
do
subject
do
Class
.
new
(
Gitlab
::
Ci
::
Status
::
Core
)
Class
.
new
(
Gitlab
::
Ci
::
Status
::
Core
)
...
@@ -10,6 +11,10 @@ describe Gitlab::Ci::Status::Pipeline::Common do
...
@@ -10,6 +11,10 @@ describe Gitlab::Ci::Status::Pipeline::Common do
.
extend
(
described_class
)
.
extend
(
described_class
)
end
end
before
do
project
.
team
<<
[
user
,
:developer
]
end
it
'does not have action'
do
it
'does not have action'
do
expect
(
subject
).
not_to
have_action
expect
(
subject
).
not_to
have_action
end
end
...
...
spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
View file @
c1db5b91
...
@@ -2,6 +2,7 @@ require 'spec_helper'
...
@@ -2,6 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Pipeline
::
Factory
do
describe
Gitlab
::
Ci
::
Status
::
Pipeline
::
Factory
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
pipeline
.
project
}
subject
do
subject
do
described_class
.
new
(
pipeline
,
user
)
described_class
.
new
(
pipeline
,
user
)
...
@@ -11,6 +12,10 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
...
@@ -11,6 +12,10 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
subject
.
fabricate!
subject
.
fabricate!
end
end
before
do
project
.
team
<<
[
user
,
:developer
]
end
context
'when pipeline has a core status'
do
context
'when pipeline has a core status'
do
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
core_status
|
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
core_status
|
context
"when core status is
#{
core_status
}
"
do
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'
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Pipeline
::
SuccessWithWarnings
do
describe
Gitlab
::
Ci
::
Status
::
Pipeline
::
SuccessWithWarnings
do
subject
do
subject
do
described_class
.
new
(
double
(
'status'
)
,
double
(
'user'
)
)
described_class
.
new
(
double
(
'status'
))
end
end
describe
'#test'
do
describe
'#test'
do
...
@@ -29,13 +29,13 @@ describe Gitlab::Ci::Status::Pipeline::SuccessWithWarnings do
...
@@ -29,13 +29,13 @@ describe Gitlab::Ci::Status::Pipeline::SuccessWithWarnings do
end
end
it
'is a correct match'
do
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
end
end
context
'when pipeline does not have warnings'
do
context
'when pipeline does not have warnings'
do
it
'does not match'
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
end
end
end
...
@@ -51,13 +51,13 @@ describe Gitlab::Ci::Status::Pipeline::SuccessWithWarnings do
...
@@ -51,13 +51,13 @@ describe Gitlab::Ci::Status::Pipeline::SuccessWithWarnings do
end
end
it
'does not match'
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
end
context
'when pipeline does not have warnings'
do
context
'when pipeline does not have warnings'
do
it
'does not match'
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
end
end
end
...
...
spec/lib/gitlab/ci/status/stage/common_spec.rb
View file @
c1db5b91
...
@@ -2,7 +2,8 @@ require 'spec_helper'
...
@@ -2,7 +2,8 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Stage
::
Common
do
describe
Gitlab
::
Ci
::
Status
::
Stage
::
Common
do
let
(
:user
)
{
create
(
:user
)
}
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
let
(
:stage
)
do
build
(
:ci_stage
,
pipeline:
pipeline
,
name:
'test'
)
build
(
:ci_stage
,
pipeline:
pipeline
,
name:
'test'
)
...
@@ -17,14 +18,26 @@ describe Gitlab::Ci::Status::Stage::Common do
...
@@ -17,14 +18,26 @@ describe Gitlab::Ci::Status::Stage::Common do
expect
(
subject
).
not_to
have_action
expect
(
subject
).
not_to
have_action
end
end
it
'has details'
do
expect
(
subject
).
to
have_details
end
it
'links to the pipeline details page'
do
it
'links to the pipeline details page'
do
expect
(
subject
.
details_path
)
expect
(
subject
.
details_path
)
.
to
include
"pipelines/
#{
pipeline
.
id
}
"
.
to
include
"pipelines/
#{
pipeline
.
id
}
"
expect
(
subject
.
details_path
)
expect
(
subject
.
details_path
)
.
to
include
"#
#{
stage
.
name
}
"
.
to
include
"#
#{
stage
.
name
}
"
end
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
end
spec/lib/gitlab/ci/status/stage/factory_spec.rb
View file @
c1db5b91
...
@@ -2,7 +2,8 @@ require 'spec_helper'
...
@@ -2,7 +2,8 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Stage
::
Factory
do
describe
Gitlab
::
Ci
::
Status
::
Stage
::
Factory
do
let
(
:user
)
{
create
(
:user
)
}
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
let
(
:stage
)
do
build
(
:ci_stage
,
pipeline:
pipeline
,
name:
'test'
)
build
(
:ci_stage
,
pipeline:
pipeline
,
name:
'test'
)
...
@@ -16,6 +17,10 @@ describe Gitlab::Ci::Status::Stage::Factory do
...
@@ -16,6 +17,10 @@ describe Gitlab::Ci::Status::Stage::Factory do
subject
.
fabricate!
subject
.
fabricate!
end
end
before
do
project
.
team
<<
[
user
,
:developer
]
end
context
'when stage has a core status'
do
context
'when stage has a core status'
do
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
core_status
|
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
core_status
|
context
"when core status is
#{
core_status
}
"
do
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