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
50985f54
Commit
50985f54
authored
May 14, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added getter for checking is their is a pipeline
parent
21f86195
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
8 deletions
+59
-8
app/assets/javascripts/ide/stores/modules/pipelines/actions.js
...ssets/javascripts/ide/stores/modules/pipelines/actions.js
+1
-3
app/assets/javascripts/ide/stores/modules/pipelines/getters.js
...ssets/javascripts/ide/stores/modules/pipelines/getters.js
+2
-0
app/assets/javascripts/ide/stores/modules/pipelines/index.js
app/assets/javascripts/ide/stores/modules/pipelines/index.js
+2
-0
app/assets/javascripts/ide/stores/modules/pipelines/mutations.js
...ets/javascripts/ide/stores/modules/pipelines/mutations.js
+7
-4
spec/javascripts/ide/stores/modules/pipelines/getters_spec.js
.../javascripts/ide/stores/modules/pipelines/getters_spec.js
+40
-0
spec/javascripts/ide/stores/modules/pipelines/mutations_spec.js
...avascripts/ide/stores/modules/pipelines/mutations_spec.js
+7
-1
No files found.
app/assets/javascripts/ide/stores/modules/pipelines/actions.js
View file @
50985f54
...
...
@@ -16,9 +16,7 @@ export const fetchLatestPipeline = ({ dispatch, rootState }, sha) => {
return
Api
.
pipelines
(
rootState
.
currentProjectId
,
{
sha
,
per_page
:
'
1
'
})
.
then
(({
data
})
=>
{
if
(
data
.
length
)
{
dispatch
(
'
receiveLatestPipelineSuccess
'
,
data
.
pop
());
}
dispatch
(
'
receiveLatestPipelineSuccess
'
,
data
.
pop
());
})
.
catch
(()
=>
dispatch
(
'
receiveLatestPipelineError
'
));
};
...
...
app/assets/javascripts/ide/stores/modules/pipelines/getters.js
0 → 100644
View file @
50985f54
// eslint-disable-next-line import/prefer-default-export
export
const
hasLatestPipeline
=
state
=>
!
state
.
isLoadingPipeline
&&
!!
state
.
latestPipeline
;
app/assets/javascripts/ide/stores/modules/pipelines/index.js
View file @
50985f54
import
state
from
'
./state
'
;
import
*
as
actions
from
'
./actions
'
;
import
mutations
from
'
./mutations
'
;
import
*
as
getters
from
'
./getters
'
;
export
default
{
namespaced
:
true
,
state
:
state
(),
actions
,
mutations
,
getters
,
};
app/assets/javascripts/ide/stores/modules/pipelines/mutations.js
View file @
50985f54
...
...
@@ -10,10 +10,13 @@ export default {
},
[
types
.
RECEIVE_LASTEST_PIPELINE_SUCCESS
](
state
,
pipeline
)
{
state
.
isLoadingPipeline
=
false
;
state
.
latestPipeline
=
{
id
:
pipeline
.
id
,
status
:
pipeline
.
status
,
};
if
(
pipeline
)
{
state
.
latestPipeline
=
{
id
:
pipeline
.
id
,
status
:
pipeline
.
status
,
};
}
},
[
types
.
REQUEST_JOBS
](
state
)
{
state
.
isLoadingJobs
=
true
;
...
...
spec/javascripts/ide/stores/modules/pipelines/getters_spec.js
0 → 100644
View file @
50985f54
import
*
as
getters
from
'
~/ide/stores/modules/pipelines/getters
'
;
import
state
from
'
~/ide/stores/modules/pipelines/state
'
;
describe
(
'
IDE pipeline getters
'
,
()
=>
{
let
mockedState
;
beforeEach
(()
=>
{
mockedState
=
state
();
});
describe
(
'
hasLatestPipeline
'
,
()
=>
{
it
(
'
returns false when loading is true
'
,
()
=>
{
mockedState
.
isLoadingPipeline
=
true
;
expect
(
getters
.
hasLatestPipeline
(
mockedState
)).
toBe
(
false
);
});
it
(
'
returns false when pipelines is null
'
,
()
=>
{
mockedState
.
latestPipeline
=
null
;
expect
(
getters
.
hasLatestPipeline
(
mockedState
)).
toBe
(
false
);
});
it
(
'
returns false when loading is true & pipelines is null
'
,
()
=>
{
mockedState
.
latestPipeline
=
null
;
mockedState
.
isLoadingPipeline
=
true
;
expect
(
getters
.
hasLatestPipeline
(
mockedState
)).
toBe
(
false
);
});
it
(
'
returns true when loading is false & pipelines is an object
'
,
()
=>
{
mockedState
.
latestPipeline
=
{
id
:
1
,
};
mockedState
.
isLoadingPipeline
=
false
;
expect
(
getters
.
hasLatestPipeline
(
mockedState
)).
toBe
(
true
);
});
});
});
spec/javascripts/ide/stores/modules/pipelines/mutations_spec.js
View file @
50985f54
...
...
@@ -7,7 +7,7 @@ describe('IDE pipelines mutations', () => {
let
mockedState
;
beforeEach
(()
=>
{
mockedState
=
state
;
mockedState
=
state
()
;
});
describe
(
types
.
REQUEST_LATEST_PIPELINE
,
()
=>
{
...
...
@@ -41,6 +41,12 @@ describe('IDE pipelines mutations', () => {
status
:
pipelines
[
0
].
status
,
});
});
it
(
'
does not set latest pipeline if pipeline is null
'
,
()
=>
{
mutations
[
types
.
RECEIVE_LASTEST_PIPELINE_SUCCESS
](
mockedState
,
null
);
expect
(
mockedState
.
latestPipeline
).
toEqual
(
null
);
});
});
describe
(
types
.
REQUEST_JOBS
,
()
=>
{
...
...
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