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
6ad56a22
Commit
6ad56a22
authored
Dec 07, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for TriggerVariableEntity
parent
c2f72ad8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
app/serializers/trigger_variable_entity.rb
app/serializers/trigger_variable_entity.rb
+1
-1
spec/serializers/trigger_variable_entity_spec.rb
spec/serializers/trigger_variable_entity_spec.rb
+48
-0
No files found.
app/serializers/trigger_variable_entity.rb
View file @
6ad56a22
...
...
@@ -4,5 +4,5 @@ class TriggerVariableEntity < Grape::Entity
include
RequestAwareEntity
expose
:key
,
:public
expose
:value
,
if:
->
(
_
,
_
)
{
request
.
project
.
team
.
maintainer?
(
request
.
current_user
)
}
expose
:value
,
if:
->
(
_
,
_
)
{
can?
(
request
.
current_user
,
:admin_build
,
request
.
project
)
}
end
spec/serializers/trigger_variable_entity_spec.rb
0 → 100644
View file @
6ad56a22
require
'spec_helper'
describe
TriggerVariableEntity
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:request
)
{
double
(
'request'
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:variable
)
{
{
key:
'TEST_KEY'
,
value:
'TEST_VALUE'
}
}
subject
{
described_class
.
new
(
variable
,
request:
request
).
as_json
}
before
do
allow
(
request
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
request
).
to
receive
(
:project
).
and_return
(
project
)
end
it
'exposes the variable key'
do
end
context
'when user has access to the value'
do
context
'when user is maintainer'
do
before
do
project
.
team
.
add_maintainer
(
user
)
end
it
'exposes the variable value'
do
expect
(
subject
).
to
include
(
:value
)
end
end
context
'when user is owner'
do
let
(
:user
)
{
project
.
owner
}
it
'exposes the variable value'
do
expect
(
subject
).
to
include
(
:value
)
end
end
end
context
'when user does not have access to the value'
do
before
do
project
.
team
.
add_developer
(
user
)
end
it
'does not expose the variable value'
do
expect
(
subject
).
not_to
include
(
:value
)
end
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