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
Léo-Paul Géneau
gitlab-ce
Commits
5de224e3
Commit
5de224e3
authored
Dec 07, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract context in JobsController spec
parent
c1a098c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
38 deletions
+40
-38
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+40
-38
No files found.
spec/controllers/projects/jobs_controller_spec.rb
View file @
5de224e3
...
@@ -398,57 +398,59 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -398,57 +398,59 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
end
end
context
'with variables
and user is a maintainer
'
do
context
'with variables'
do
before
do
before
do
project
.
add_maintainer
(
user
)
create
(
:ci_pipeline_variable
,
pipeline:
pipeline
,
key: :TRIGGER_KEY_1
,
value:
'TRIGGER_VALUE_1'
)
create
(
:ci_pipeline_variable
,
pipeline:
pipeline
,
key: :TRIGGER_KEY_1
,
value:
'TRIGGER_VALUE_1'
)
get_show
(
id:
job
.
id
,
format: :json
)
@first_variable
=
json_response
[
'trigger'
][
'variables'
].
first
end
end
it
'returns a job_detail'
do
context
'user is a maintainer'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
before
do
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
project
.
add_maintainer
(
user
)
end
it
'exposes trigger information and variables'
do
get_show
(
id:
job
.
id
,
format: :json
)
expect
(
json_response
[
'trigger'
][
'short_token'
]).
to
eq
'toke'
end
expect
(
json_response
[
'trigger'
][
'variables'
].
length
).
to
eq
1
end
it
'exposes correct variable properties'
do
it
'returns a job_detail'
do
expect
(
@first_variable
[
'key'
]).
to
eq
"TRIGGER_KEY_1"
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
@first_variable
[
'value'
]).
to
eq
"TRIGGER_VALUE_1"
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
@first_variable
[
'public'
]).
to
eq
false
end
end
end
context
'with variables and user is not a mantainer'
do
it
'exposes trigger information and variables'
do
before
do
expect
(
json_response
[
'trigger'
][
'short_token'
]).
to
eq
'toke'
create
(
:ci_pipeline_variable
,
pipeline:
pipeline
,
key: :TRIGGER_KEY_1
,
value:
'TRIGGER_VALUE_1'
)
expect
(
json_response
[
'trigger'
][
'variables'
].
length
).
to
eq
1
end
get_show
(
id:
job
.
id
,
format: :json
)
it
'exposes correct variable properties'
do
first_variable
=
json_response
[
'trigger'
][
'variables'
].
first
@first_variable
=
json_response
[
'trigger'
][
'variables'
].
first
expect
(
first_variable
[
'key'
]).
to
eq
"TRIGGER_KEY_1"
expect
(
first_variable
[
'value'
]).
to
eq
"TRIGGER_VALUE_1"
expect
(
first_variable
[
'public'
]).
to
eq
false
end
end
end
it
'returns a job_detail
'
do
context
'user is not a mantainer
'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
before
do
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
get_show
(
id:
job
.
id
,
format: :json
)
end
end
it
'exposes trigger information and variables
'
do
it
'returns a job_detail
'
do
expect
(
json_response
[
'trigger'
][
'short_token'
]).
to
eq
'toke'
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'trigger'
][
'variables'
].
length
).
to
eq
1
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
end
end
it
'exposes correct variable properties'
do
it
'exposes trigger information and variables'
do
expect
(
@first_variable
[
'key'
]).
to
eq
"TRIGGER_KEY_1"
expect
(
json_response
[
'trigger'
][
'short_token'
]).
to
eq
'toke'
expect
(
@first_variable
[
'value'
]).
to
be_nil
expect
(
json_response
[
'trigger'
][
'variables'
].
length
).
to
eq
1
expect
(
@first_variable
[
'public'
]).
to
eq
false
end
it
'exposes correct variable properties'
do
first_variable
=
json_response
[
'trigger'
][
'variables'
].
first
expect
(
first_variable
[
'key'
]).
to
eq
"TRIGGER_KEY_1"
expect
(
first_variable
[
'value'
]).
to
be_nil
expect
(
first_variable
[
'public'
]).
to
eq
false
end
end
end
end
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