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
974c3c13
Commit
974c3c13
authored
Mar 15, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Normalize wording
parent
2e43e50e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
47 deletions
+39
-47
spec/finders/pipelines_finder_spec.rb
spec/finders/pipelines_finder_spec.rb
+39
-47
No files found.
spec/finders/pipelines_finder_spec.rb
View file @
974c3c13
...
@@ -23,7 +23,7 @@ describe PipelinesFinder do
...
@@ -23,7 +23,7 @@ describe PipelinesFinder do
context
'when nothing is passed'
do
context
'when nothing is passed'
do
let
(
:params
)
{
{}
}
let
(
:params
)
{
{}
}
it
'
select
s all pipelines'
do
it
'
return
s all pipelines'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
all
)
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
all
)
end
end
...
@@ -33,92 +33,92 @@ describe PipelinesFinder do
...
@@ -33,92 +33,92 @@ describe PipelinesFinder do
end
end
context
'when scope is passed'
do
context
'when scope is passed'
do
context
'when s
electing
running'
do
context
'when s
cope is
running'
do
let
(
:params
)
{
{
scope:
'running'
}
}
let
(
:params
)
{
{
scope:
'running'
}
}
it
'
has only running statu
s'
do
it
'
returns matched pipeline
s'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
running
)
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
running
)
end
end
end
end
context
'when s
electing
pending'
do
context
'when s
cope is
pending'
do
let
(
:params
)
{
{
scope:
'pending'
}
}
let
(
:params
)
{
{
scope:
'pending'
}
}
it
'
has only pending statu
s'
do
it
'
returns matched pipeline
s'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
pending
)
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
pending
)
end
end
end
end
context
'when s
electing
finished'
do
context
'when s
cope is
finished'
do
let
(
:params
)
{
{
scope:
'finished'
}
}
let
(
:params
)
{
{
scope:
'finished'
}
}
it
'
has only finished statu
s'
do
it
'
returns matched pipeline
s'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
finished
)
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
finished
)
end
end
end
end
context
'when s
electing
branches'
do
context
'when s
cope is
branches'
do
let
(
:params
)
{
{
scope:
'branches'
}
}
let
(
:params
)
{
{
scope:
'branches'
}
}
it
'
excludes tag
s'
do
it
'
returns matched pipeline
s'
do
expect
(
subject
).
to
eq
([
Ci
::
Pipeline
.
where
(
tag:
false
).
last
])
expect
(
subject
).
to
eq
([
Ci
::
Pipeline
.
where
(
tag:
false
).
last
])
end
end
end
end
context
'when s
electing
tags'
do
context
'when s
cope is
tags'
do
let
(
:params
)
{
{
scope:
'tags'
}
}
let
(
:params
)
{
{
scope:
'tags'
}
}
it
'
excludes branch
es'
do
it
'
returns matched pipelin
es'
do
expect
(
subject
).
to
eq
([
Ci
::
Pipeline
.
where
(
tag:
true
).
last
])
expect
(
subject
).
to
eq
([
Ci
::
Pipeline
.
where
(
tag:
true
).
last
])
end
end
end
end
end
end
context
'when status is passed'
do
context
'when status is passed'
do
context
'when s
electing
running'
do
context
'when s
tatus is
running'
do
let
(
:params
)
{
{
status:
'running'
}
}
let
(
:params
)
{
{
status:
'running'
}
}
it
'
has only running statu
s'
do
it
'
returns matched pipeline
s'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
running
)
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
running
)
end
end
end
end
context
'when s
electing
pending'
do
context
'when s
tatus is
pending'
do
let
(
:params
)
{
{
status:
'pending'
}
}
let
(
:params
)
{
{
status:
'pending'
}
}
it
'
has only pending statu
s'
do
it
'
returns matched pipeline
s'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
pending
)
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
pending
)
end
end
end
end
context
'when s
electing
success'
do
context
'when s
tatus is
success'
do
let
(
:params
)
{
{
status:
'success'
}
}
let
(
:params
)
{
{
status:
'success'
}
}
it
'
has only success statu
s'
do
it
'
returns matched pipeline
s'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
success
)
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
success
)
end
end
end
end
context
'when s
electing
failed'
do
context
'when s
tatus is
failed'
do
let
(
:params
)
{
{
status:
'failed'
}
}
let
(
:params
)
{
{
status:
'failed'
}
}
it
'
has only failed statu
s'
do
it
'
returns matched pipeline
s'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
failed
)
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
failed
)
end
end
end
end
context
'when s
electing
canceled'
do
context
'when s
tatus is
canceled'
do
let
(
:params
)
{
{
status:
'canceled'
}
}
let
(
:params
)
{
{
status:
'canceled'
}
}
it
'
has only canceled statu
s'
do
it
'
returns matched pipeline
s'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
canceled
)
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
canceled
)
end
end
end
end
context
'when s
electing
skipped'
do
context
'when s
tatus is
skipped'
do
let
(
:params
)
{
{
status:
'skipped'
}
}
let
(
:params
)
{
{
status:
'skipped'
}
}
it
'
has only skipped statu
s'
do
it
'
returns matched pipeline
s'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
skipped
)
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
skipped
)
end
end
end
end
...
@@ -128,7 +128,7 @@ describe PipelinesFinder do
...
@@ -128,7 +128,7 @@ describe PipelinesFinder do
context
'when ref exists'
do
context
'when ref exists'
do
let
(
:params
)
{
{
ref:
'master'
}
}
let
(
:params
)
{
{
ref:
'master'
}
}
it
'
selects all pipelines which belong to the ref
'
do
it
'
returns matched pipelines
'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
where
(
ref:
'master'
))
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
where
(
ref:
'master'
))
end
end
end
end
...
@@ -136,7 +136,7 @@ describe PipelinesFinder do
...
@@ -136,7 +136,7 @@ describe PipelinesFinder do
context
'when ref does not exist'
do
context
'when ref does not exist'
do
let
(
:params
)
{
{
ref:
'invalid-ref'
}
}
let
(
:params
)
{
{
ref:
'invalid-ref'
}
}
it
'
selects nothing
'
do
it
'
returns empty
'
do
expect
(
subject
).
to
be_empty
expect
(
subject
).
to
be_empty
end
end
end
end
...
@@ -146,7 +146,7 @@ describe PipelinesFinder do
...
@@ -146,7 +146,7 @@ describe PipelinesFinder do
context
'when name exists'
do
context
'when name exists'
do
let
(
:params
)
{
{
name:
user1
.
name
}
}
let
(
:params
)
{
{
name:
user1
.
name
}
}
it
'
selects all pipelines which belong to the name
'
do
it
'
returns matched pipelines
'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
where
(
user:
user1
))
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
where
(
user:
user1
))
end
end
end
end
...
@@ -154,7 +154,7 @@ describe PipelinesFinder do
...
@@ -154,7 +154,7 @@ describe PipelinesFinder do
context
'when name does not exist'
do
context
'when name does not exist'
do
let
(
:params
)
{
{
name:
'invalid-name'
}
}
let
(
:params
)
{
{
name:
'invalid-name'
}
}
it
'
selects nothing
'
do
it
'
returns empty
'
do
expect
(
subject
).
to
be_empty
expect
(
subject
).
to
be_empty
end
end
end
end
...
@@ -164,7 +164,7 @@ describe PipelinesFinder do
...
@@ -164,7 +164,7 @@ describe PipelinesFinder do
context
'when username exists'
do
context
'when username exists'
do
let
(
:params
)
{
{
username:
user1
.
username
}
}
let
(
:params
)
{
{
username:
user1
.
username
}
}
it
'
selects all pipelines which belong to the username
'
do
it
'
returns matched pipelines
'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
where
(
user:
user1
))
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
where
(
user:
user1
))
end
end
end
end
...
@@ -172,7 +172,7 @@ describe PipelinesFinder do
...
@@ -172,7 +172,7 @@ describe PipelinesFinder do
context
'when username does not exist'
do
context
'when username does not exist'
do
let
(
:params
)
{
{
username:
'invalid-username'
}
}
let
(
:params
)
{
{
username:
'invalid-username'
}
}
it
'
selects nothing
'
do
it
'
returns empty
'
do
expect
(
subject
).
to
be_empty
expect
(
subject
).
to
be_empty
end
end
end
end
...
@@ -182,7 +182,7 @@ describe PipelinesFinder do
...
@@ -182,7 +182,7 @@ describe PipelinesFinder do
context
'when yaml_errors is true'
do
context
'when yaml_errors is true'
do
let
(
:params
)
{
{
yaml_errors:
true
}
}
let
(
:params
)
{
{
yaml_errors:
true
}
}
it
'
selects only pipelines have yaml_error
s'
do
it
'
returns matched pipeline
s'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
where
(
"yaml_errors IS NOT NULL"
))
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
where
(
"yaml_errors IS NOT NULL"
))
end
end
end
end
...
@@ -190,49 +190,41 @@ describe PipelinesFinder do
...
@@ -190,49 +190,41 @@ describe PipelinesFinder do
context
'when yaml_errors is false'
do
context
'when yaml_errors is false'
do
let
(
:params
)
{
{
yaml_errors:
false
}
}
let
(
:params
)
{
{
yaml_errors:
false
}
}
it
'
selects only pipelines do not have yaml_error
s'
do
it
'
returns matched pipeline
s'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
where
(
"yaml_errors IS NULL"
))
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
where
(
"yaml_errors IS NULL"
))
end
end
end
end
context
'when
an argument
is invalid'
do
context
'when
yaml_errors
is invalid'
do
let
(
:params
)
{
{
yaml_errors:
"UnexpectedValue"
}
}
let
(
:params
)
{
{
yaml_errors:
"UnexpectedValue"
}
}
it
'
select
s all pipelines'
do
it
'
return
s all pipelines'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
all
)
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
all
)
end
end
end
end
end
end
context
'when order_by and sort are passed'
do
context
'when order_by and sort are passed'
do
context
'when order
by created_at asc
'
do
context
'when order
_by and sort are valid
'
do
let
(
:params
)
{
{
order_by:
'created_at'
,
sort:
'asc'
}
}
let
(
:params
)
{
{
order_by:
'created_at'
,
sort:
'asc'
}
}
it
'sorts
by created_at asc
'
do
it
'sorts
pipelines
'
do
expect
(
subject
).
to
eq
(
Ci
::
Pipeline
.
order
(
created_at: :asc
))
expect
(
subject
).
to
eq
(
Ci
::
Pipeline
.
order
(
created_at: :asc
))
end
end
end
end
context
'when order by created_at desc'
do
context
'when order_by is invalid'
do
let
(
:params
)
{
{
order_by:
'created_at'
,
sort:
'desc'
}
}
it
'sorts by created_at desc'
do
expect
(
subject
).
to
eq
(
Ci
::
Pipeline
.
order
(
created_at: :desc
))
end
end
context
'when order_by does not exist'
do
let
(
:params
)
{
{
order_by:
'invalid_column'
,
sort:
'desc'
}
}
let
(
:params
)
{
{
order_by:
'invalid_column'
,
sort:
'desc'
}
}
it
'sorts
by
default'
do
it
'sorts
pipelines, but order_by is
default'
do
expect
(
subject
).
to
eq
(
Ci
::
Pipeline
.
order
(
id: :desc
))
expect
(
subject
).
to
eq
(
Ci
::
Pipeline
.
order
(
id: :desc
))
end
end
end
end
context
'when sort
does not exist
'
do
context
'when sort
is invalid
'
do
let
(
:params
)
{
{
order_by:
'created_at'
,
sort:
'invalid_sort'
}
}
let
(
:params
)
{
{
order_by:
'created_at'
,
sort:
'invalid_sort'
}
}
it
'sorts
by
default'
do
it
'sorts
pipelines, but sort is
default'
do
expect
(
subject
).
to
eq
(
Ci
::
Pipeline
.
order
(
created_at: :desc
))
expect
(
subject
).
to
eq
(
Ci
::
Pipeline
.
order
(
created_at: :desc
))
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