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
Jérome Perrin
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
context
'when nothing is passed'
do
let
(
:params
)
{
{}
}
it
'
select
s all pipelines'
do
it
'
return
s all pipelines'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
all
)
end
...
...
@@ -33,92 +33,92 @@ describe PipelinesFinder do
end
context
'when scope is passed'
do
context
'when s
electing
running'
do
context
'when s
cope is
running'
do
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
)
end
end
context
'when s
electing
pending'
do
context
'when s
cope is
pending'
do
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
)
end
end
context
'when s
electing
finished'
do
context
'when s
cope is
finished'
do
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
)
end
end
context
'when s
electing
branches'
do
context
'when s
cope is
branches'
do
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
])
end
end
context
'when s
electing
tags'
do
context
'when s
cope is
tags'
do
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
])
end
end
end
context
'when status is passed'
do
context
'when s
electing
running'
do
context
'when s
tatus is
running'
do
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
)
end
end
context
'when s
electing
pending'
do
context
'when s
tatus is
pending'
do
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
)
end
end
context
'when s
electing
success'
do
context
'when s
tatus is
success'
do
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
)
end
end
context
'when s
electing
failed'
do
context
'when s
tatus is
failed'
do
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
)
end
end
context
'when s
electing
canceled'
do
context
'when s
tatus is
canceled'
do
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
)
end
end
context
'when s
electing
skipped'
do
context
'when s
tatus is
skipped'
do
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
)
end
end
...
...
@@ -128,7 +128,7 @@ describe PipelinesFinder do
context
'when ref exists'
do
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'
))
end
end
...
...
@@ -136,7 +136,7 @@ describe PipelinesFinder do
context
'when ref does not exist'
do
let
(
:params
)
{
{
ref:
'invalid-ref'
}
}
it
'
selects nothing
'
do
it
'
returns empty
'
do
expect
(
subject
).
to
be_empty
end
end
...
...
@@ -146,7 +146,7 @@ describe PipelinesFinder do
context
'when name exists'
do
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
))
end
end
...
...
@@ -154,7 +154,7 @@ describe PipelinesFinder do
context
'when name does not exist'
do
let
(
:params
)
{
{
name:
'invalid-name'
}
}
it
'
selects nothing
'
do
it
'
returns empty
'
do
expect
(
subject
).
to
be_empty
end
end
...
...
@@ -164,7 +164,7 @@ describe PipelinesFinder do
context
'when username exists'
do
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
))
end
end
...
...
@@ -172,7 +172,7 @@ describe PipelinesFinder do
context
'when username does not exist'
do
let
(
:params
)
{
{
username:
'invalid-username'
}
}
it
'
selects nothing
'
do
it
'
returns empty
'
do
expect
(
subject
).
to
be_empty
end
end
...
...
@@ -182,7 +182,7 @@ describe PipelinesFinder do
context
'when yaml_errors is true'
do
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"
))
end
end
...
...
@@ -190,49 +190,41 @@ describe PipelinesFinder do
context
'when yaml_errors is false'
do
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"
))
end
end
context
'when
an argument
is invalid'
do
context
'when
yaml_errors
is invalid'
do
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
)
end
end
end
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'
}
}
it
'sorts
by created_at asc
'
do
it
'sorts
pipelines
'
do
expect
(
subject
).
to
eq
(
Ci
::
Pipeline
.
order
(
created_at: :asc
))
end
end
context
'when order by created_at desc'
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
context
'when order_by is invalid'
do
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
))
end
end
context
'when sort
does not exist
'
do
context
'when sort
is invalid
'
do
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
))
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