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
1bf28d48
Commit
1bf28d48
authored
Dec 06, 2018
by
jhampton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjusts tests per MR feedback
- Updates tests / applies patterns per MR feedback
parent
242bead1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
33 deletions
+75
-33
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+31
-10
spec/features/projects/jobs_spec.rb
spec/features/projects/jobs_spec.rb
+44
-23
No files found.
spec/controllers/projects/jobs_controller_spec.rb
View file @
1bf28d48
...
...
@@ -398,40 +398,61 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
context
'with variables'
do
context
'with variables
and user is a maintainer
'
do
before
do
project
.
add_maintainer
(
user
)
create
(
:ci_pipeline_variable
,
pipeline:
pipeline
,
key: :TRIGGER_KEY_1
,
value:
'TRIGGER_VALUE_1'
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'exposes trigger information and variables'
do
before
(
:each
)
do
@first_variable
=
json_response
[
'trigger'
][
'variables'
].
first
end
it
'returns a job_detail'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
end
it
'exposes trigger information and variables'
do
expect
(
json_response
[
'trigger'
][
'short_token'
]).
to
eq
'toke'
expect
(
json_response
[
'trigger'
][
'variables'
].
length
).
to
eq
1
expect
(
json_response
[
'trigger'
][
'variables'
].
first
[
'key'
]).
to
eq
"TRIGGER_KEY_1"
expect
(
json_response
[
'trigger'
][
'variables'
].
first
[
'value'
]).
to
eq
"TRIGGER_VALUE_1"
expect
(
json_response
[
'trigger'
][
'variables'
].
first
[
'public'
]).
to
eq
false
end
it
'exposes correct variable properties'
do
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
context
'with
no variable values
'
do
context
'with
variables and user is not a mantainer
'
do
before
do
create
(
:ci_pipeline_variable
,
pipeline:
pipeline
,
key: :TRIGGER_KEY_1
,
value:
'TRIGGER_VALUE_1'
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'exposes trigger information and variables'
do
before
(
:each
)
do
@first_variable
=
json_response
[
'trigger'
][
'variables'
].
first
end
it
'returns a job_detail'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
end
it
'exposes trigger information and variables'
do
expect
(
json_response
[
'trigger'
][
'short_token'
]).
to
eq
'toke'
expect
(
json_response
[
'trigger'
][
'variables'
].
length
).
to
eq
1
expect
(
json_response
[
'trigger'
][
'variables'
].
first
[
'key'
]).
to
eq
"TRIGGER_KEY_1"
expect
(
json_response
[
'trigger'
][
'variables'
].
first
[
'value'
]).
to
be_nil
expect
(
json_response
[
'trigger'
][
'variables'
].
first
[
'public'
]).
to
eq
false
end
it
'exposes correct variable properties'
do
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
...
...
spec/features/projects/jobs_spec.rb
View file @
1bf28d48
...
...
@@ -344,65 +344,86 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
end
end
describe
'Variables when user is a maintainer'
do
before
do
project
.
add_maintainer
(
user
)
end
describe
'Pipeline trigger variables when user is not a maintainer'
do
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
)
}
let!
(
:trigger_request
)
{
create
(
:ci_trigger_request
)
}
let!
(
:job
)
do
create
(
:ci_build
,
pipeline:
pipeline
,
trigger_request:
trigger_request
)
end
let
(
:job
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
trigger_request:
trigger_request
)
}
shared_examples
'
job with outdated deployment
'
do
it
'
shows a link for the job'
do
shared_examples
'
expected variables behavior
'
do
it
'
renders a hidden value with no reveal values button'
,
:js
do
expect
(
page
).
to
have_content
(
'Token'
)
expect
(
page
).
to
have_content
(
'Variables'
)
expect
(
page
).
not_to
have_css
(
'.js-reveal-variables'
)
expect
(
page
).
to
have_selector
(
'.js-build-variable'
,
text:
'TRIGGER_KEY_1'
)
expect
(
page
).
to
have_selector
(
'.js-build-value'
,
text:
'••••••'
)
end
end
click_button
'Reveal values'
context
'when variables are stored in trigger_request'
do
before
do
trigger_request
.
update_attribute
(
:variables
,
{
'TRIGGER_KEY_1'
=>
'TRIGGER_VALUE_1'
}
)
expect
(
page
).
to
have_css
(
'.js-reveal-variables'
)
expect
(
page
).
to
have_selector
(
'.js-build-variable'
,
text:
'TRIGGER_KEY_1'
)
expect
(
page
).
to
have_selector
(
'.js-build-value'
,
text:
'TRIGGER_VALUE_1'
)
visit
project_job_path
(
project
,
job
)
end
it_behaves_like
'expected variables behavior'
end
context
'when variables are stored in pipeline_variables'
do
before
do
create
(
:ci_pipeline_variable
,
pipeline:
pipeline
,
key:
'TRIGGER_KEY_1'
,
value:
'TRIGGER_VALUE_1'
)
visit
project_job_path
(
project
,
job
)
end
it_behaves_like
'expected variables behavior'
end
end
describe
'
Variables
'
do
describe
'
Pipeline trigger variables when user is a maintainer
'
do
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
)
}
let
(
:job
)
do
create
(
:ci_build
,
pipeline:
pipeline
,
trigger_request:
trigger_request
)
end
let
(
:job
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
trigger_request:
trigger_request
)
}
shared_examples
'expected variables behavior'
do
it
'renders a hidden value with
no
reveal values button'
,
:js
do
shared_examples
'expected variables behavior
when maintainer
'
do
it
'renders a hidden value with
a
reveal values button'
,
:js
do
expect
(
page
).
to
have_content
(
'Token'
)
expect
(
page
).
to
have_content
(
'Variables'
)
expect
(
page
).
not_
to
have_css
(
'.js-reveal-variables'
)
expect
(
page
).
to
have_css
(
'.js-reveal-variables'
)
expect
(
page
).
to
have_selector
(
'.js-build-variable'
,
text:
'TRIGGER_KEY_1'
)
expect
(
page
).
to
have_selector
(
'.js-build-value'
,
text:
'••••••'
)
end
it
'reveals values on button click'
,
:js
do
click_button
'Reveal values'
expect
(
page
).
to
have_selector
(
'.js-build-variable'
,
text:
'TRIGGER_KEY_1'
)
expect
(
page
).
to
have_selector
(
'.js-build-value'
,
text:
'TRIGGER_VALUE_1'
)
end
end
context
'when variables are stored in trigger_request'
do
before
do
project
.
add_maintainer
(
user
)
trigger_request
.
update_attribute
(
:variables
,
{
'TRIGGER_KEY_1'
=>
'TRIGGER_VALUE_1'
}
)
visit
project_job_path
(
project
,
job
)
end
it_behaves_like
'expected variables behavior'
it_behaves_like
'expected variables behavior
when maintainer
'
end
context
'when variables are stored in pipeline_variables'
do
before
do
project
.
add_maintainer
(
user
)
create
(
:ci_pipeline_variable
,
pipeline:
pipeline
,
key:
'TRIGGER_KEY_1'
,
value:
'TRIGGER_VALUE_1'
)
visit
project_job_path
(
project
,
job
)
end
it_behaves_like
'expected variables behavior'
it_behaves_like
'expected variables behavior
when maintainer
'
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