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
3ae20381
Commit
3ae20381
authored
Sep 02, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove ci_trigger_request_with_variables
parent
d614c431
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
92 additions
and
48 deletions
+92
-48
app/presenters/ci/build_presenter.rb
app/presenters/ci/build_presenter.rb
+11
-0
app/views/projects/jobs/_sidebar.html.haml
app/views/projects/jobs/_sidebar.html.haml
+2
-2
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+1
-1
spec/factories/ci/pipeline_variables.rb
spec/factories/ci/pipeline_variables.rb
+0
-0
spec/factories/ci/trigger_requests.rb
spec/factories/ci/trigger_requests.rb
+0
-8
spec/features/projects/jobs_spec.rb
spec/features/projects/jobs_spec.rb
+29
-11
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+24
-4
spec/requests/api/runner_spec.rb
spec/requests/api/runner_spec.rb
+25
-6
spec/views/projects/jobs/show.html.haml_spec.rb
spec/views/projects/jobs/show.html.haml_spec.rb
+0
-16
No files found.
app/presenters/ci/build_presenter.rb
View file @
3ae20381
...
@@ -17,5 +17,16 @@ module Ci
...
@@ -17,5 +17,16 @@ module Ci
"Job is redundant and is auto-canceled by Pipeline #
#{
auto_canceled_by_id
}
"
"Job is redundant and is auto-canceled by Pipeline #
#{
auto_canceled_by_id
}
"
end
end
end
end
def
old_or_new_trigger_variables
return
@old_or_new_trigger_variables
if
defined?
(
@old_or_new_trigger_variables
)
if
build
.
pipeline
.
variables
.
any?
@old_or_new_trigger_variables
=
build
.
pipeline
.
variables
&
.
map
{
|
v
|
{
v
.
key
=>
v
.
value
}
}
&
.
reduce
({},
:merge
)
else
@old_or_new_trigger_variables
=
build
.
trigger_request
.
variables
end
end
end
end
end
end
app/views/projects/jobs/_sidebar.html.haml
View file @
3ae20381
...
@@ -46,12 +46,12 @@
...
@@ -46,12 +46,12 @@
%span
.build-light-text
Token:
%span
.build-light-text
Token:
#{
@build
.
trigger_request
.
trigger
.
short_token
}
#{
@build
.
trigger_request
.
trigger
.
short_token
}
-
if
@build
.
trigger_request
.
variables
-
if
@build
.
old_or_new_trigger_
variables
%p
%p
%button
.btn.group.btn-group-justified.reveal-variables
Reveal Variables
%button
.btn.group.btn-group-justified.reveal-variables
Reveal Variables
%dl
.js-build-variables.trigger-build-variables.hide
%dl
.js-build-variables.trigger-build-variables.hide
-
@build
.
trigger_request
.
variables
.
each
do
|
key
,
value
|
-
@build
.
old_or_new_trigger_
variables
.
each
do
|
key
,
value
|
%dt
.js-build-variable.trigger-build-variable
=
key
%dt
.js-build-variable.trigger-build-variable
=
key
%dd
.js-build-value.trigger-build-value
=
value
%dd
.js-build-value.trigger-build-value
=
value
...
...
spec/factories/ci/builds.rb
View file @
3ae20381
...
@@ -107,7 +107,7 @@ FactoryGirl.define do
...
@@ -107,7 +107,7 @@ FactoryGirl.define do
end
end
trait
:triggered
do
trait
:triggered
do
trigger_request
factory: :ci_trigger_request
_with_variables
trigger_request
factory: :ci_trigger_request
end
end
after
(
:build
)
do
|
build
,
evaluator
|
after
(
:build
)
do
|
build
,
evaluator
|
...
...
spec/factories/ci/pipeline_variable
_variable
s.rb
→
spec/factories/ci/pipeline_variables.rb
View file @
3ae20381
File moved
spec/factories/ci/trigger_requests.rb
View file @
3ae20381
FactoryGirl
.
define
do
FactoryGirl
.
define
do
factory
:ci_trigger_request
,
class:
Ci
::
TriggerRequest
do
factory
:ci_trigger_request
,
class:
Ci
::
TriggerRequest
do
trigger
factory: :ci_trigger
trigger
factory: :ci_trigger
# We switched to Ci::PipelineVariable from Ci::TriggerRequest.variables.
# Ci::TriggerRequest doesn't save variables anymore, whereas old trigger requests still persist variables.
factory
:ci_trigger_request_with_variables
do
after
(
:create
)
do
|
trigger_request
,
evaluator
|
trigger_request
.
update_attribute
(
:variables
,
{
TRIGGER_KEY_1
:
'TRIGGER_VALUE_1'
,
TRIGGER_KEY_2
:
'TRIGGER_VALUE_2'
}
)
end
end
end
end
end
end
spec/features/projects/jobs_spec.rb
View file @
3ae20381
...
@@ -292,26 +292,44 @@ feature 'Jobs' do
...
@@ -292,26 +292,44 @@ feature 'Jobs' do
end
end
feature
'Variables'
do
feature
'Variables'
do
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
_with_variables
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
)
}
let
(
:job
)
do
let
(
:job
)
do
create
:ci_build
,
pipeline:
pipeline
,
trigger_request:
trigger_request
create
:ci_build
,
pipeline:
pipeline
,
trigger_request:
trigger_request
end
end
before
do
shared_examples
'expected variables behavior'
do
visit
project_job_path
(
project
,
job
)
it
'shows variable key and value after click'
,
js:
true
do
expect
(
page
).
to
have_css
(
'.reveal-variables'
)
expect
(
page
).
not_to
have_css
(
'.js-build-variable'
)
expect
(
page
).
not_to
have_css
(
'.js-build-value'
)
click_button
'Reveal Variables'
expect
(
page
).
not_to
have_css
(
'.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'
)
end
end
end
it
'shows variable key and value after click'
,
js:
true
do
context
'when variables are stored in trigger_request'
do
expect
(
page
).
to
have_css
(
'.reveal-variables'
)
before
do
expect
(
page
).
not_to
have_css
(
'.js-build-variable'
)
trigger_request
.
update_attribute
(
:variables
,
{
'TRIGGER_KEY_1'
=>
'TRIGGER_VALUE_1'
}
)
expect
(
page
).
not_to
have_css
(
'.js-build-value'
)
click_button
'Reveal Variables'
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
expect
(
page
).
not_to
have_css
(
'.reveal-variables'
)
it_behaves_like
'expected variables behavior'
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
end
end
...
...
spec/models/ci/build_spec.rb
View file @
3ae20381
...
@@ -1492,10 +1492,12 @@ describe Ci::Build do
...
@@ -1492,10 +1492,12 @@ describe Ci::Build do
context
'when build is for triggers'
do
context
'when build is for triggers'
do
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request_with_variables
,
pipeline:
pipeline
,
trigger:
trigger
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
,
pipeline:
pipeline
,
trigger:
trigger
)
}
let
(
:user_trigger_variable
)
do
let
(
:user_trigger_variable
)
do
{
key:
:TRIGGER_KEY_1
,
value:
'TRIGGER_VALUE_1'
,
public:
false
}
{
key:
'TRIGGER_KEY_1'
,
value:
'TRIGGER_VALUE_1'
,
public:
false
}
end
end
let
(
:predefined_trigger_variable
)
do
let
(
:predefined_trigger_variable
)
do
{
key:
'CI_PIPELINE_TRIGGERED'
,
value:
'true'
,
public:
true
}
{
key:
'CI_PIPELINE_TRIGGERED'
,
value:
'true'
,
public:
true
}
end
end
...
@@ -1504,8 +1506,26 @@ describe Ci::Build do
...
@@ -1504,8 +1506,26 @@ describe Ci::Build do
build
.
trigger_request
=
trigger_request
build
.
trigger_request
=
trigger_request
end
end
it
{
is_expected
.
to
include
(
user_trigger_variable
)
}
shared_examples
'returns variables for triggers'
do
it
{
is_expected
.
to
include
(
predefined_trigger_variable
)
}
it
{
is_expected
.
to
include
(
user_trigger_variable
)
}
it
{
is_expected
.
to
include
(
predefined_trigger_variable
)
}
end
context
'when variables are stored in trigger_request'
do
before
do
trigger_request
.
update_attribute
(
:variables
,
{
'TRIGGER_KEY_1'
=>
'TRIGGER_VALUE_1'
}
)
end
it_behaves_like
'returns variables for triggers'
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'
)
end
it_behaves_like
'returns variables for triggers'
end
end
end
context
'when pipeline has a variable'
do
context
'when pipeline has a variable'
do
...
...
spec/requests/api/runner_spec.rb
View file @
3ae20381
...
@@ -557,17 +557,36 @@ describe API::Runner do
...
@@ -557,17 +557,36 @@ describe API::Runner do
{
'key'
=>
'TRIGGER_KEY_1'
,
'value'
=>
'TRIGGER_VALUE_1'
,
'public'
=>
false
}]
{
'key'
=>
'TRIGGER_KEY_1'
,
'value'
=>
'TRIGGER_VALUE_1'
,
'public'
=>
false
}]
end
end
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let!
(
:trigger_request
)
{
create
(
:ci_trigger_request
,
pipeline:
pipeline
,
builds:
[
job
],
trigger:
trigger
)
}
before
do
before
do
trigger
=
create
(
:ci_trigger
,
project:
project
)
create
(
:ci_trigger_request_with_variables
,
pipeline:
pipeline
,
builds:
[
job
],
trigger:
trigger
)
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
'SECRET_KEY'
,
value:
'secret_value'
)
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
'SECRET_KEY'
,
value:
'secret_value'
)
end
end
it
'returns variables for triggers'
do
shared_examples
'expected variables behavior'
do
request_job
it
'returns variables for triggers'
do
request_job
expect
(
response
).
to
have_http_status
(
201
)
expect
(
response
).
to
have_http_status
(
201
)
expect
(
json_response
[
'variables'
]).
to
include
(
*
expected_variables
)
expect
(
json_response
[
'variables'
]).
to
include
(
*
expected_variables
)
end
end
context
'when variables are stored in trigger_request'
do
before
do
trigger_request
.
update_attribute
(
:variables
,
{
TRIGGER_KEY_1
:
'TRIGGER_VALUE_1'
}
)
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'
)
end
it_behaves_like
'expected variables behavior'
end
end
end
end
...
...
spec/views/projects/jobs/show.html.haml_spec.rb
View file @
3ae20381
...
@@ -195,20 +195,4 @@ describe 'projects/jobs/show' do
...
@@ -195,20 +195,4 @@ describe 'projects/jobs/show' do
text:
/\A\n
#{
Regexp
.
escape
(
commit_title
)
}
\n\Z/
)
text:
/\A\n
#{
Regexp
.
escape
(
commit_title
)
}
\n\Z/
)
end
end
end
end
describe
'shows trigger variables in sidebar'
do
let
(
:trigger_request
)
{
create
(
:ci_trigger_request_with_variables
,
pipeline:
pipeline
)
}
before
do
build
.
trigger_request
=
trigger_request
render
end
it
'shows trigger variables in separate lines'
do
expect
(
rendered
).
to
have_css
(
'.js-build-variable'
,
visible:
false
,
text:
'TRIGGER_KEY_1'
)
expect
(
rendered
).
to
have_css
(
'.js-build-variable'
,
visible:
false
,
text:
'TRIGGER_KEY_2'
)
expect
(
rendered
).
to
have_css
(
'.js-build-value'
,
visible:
false
,
text:
'TRIGGER_VALUE_1'
)
expect
(
rendered
).
to
have_css
(
'.js-build-value'
,
visible:
false
,
text:
'TRIGGER_VALUE_2'
)
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