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
5f3291f8
Commit
5f3291f8
authored
Jul 27, 2021
by
Pedro Pombeiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix naming of RunnersFinder specs
parent
a014c2b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
60 deletions
+64
-60
spec/finders/ci/runners_finder_spec.rb
spec/finders/ci/runners_finder_spec.rb
+64
-60
No files found.
spec/finders/ci/runners_finder_spec.rb
View file @
5f3291f8
...
...
@@ -33,41 +33,43 @@ RSpec.describe Ci::RunnersFinder do
end
end
context
'filter by search term'
do
it
'calls Ci::Runner.search'
do
expect
(
Ci
::
Runner
).
to
receive
(
:search
).
with
(
'term'
).
and_call_original
context
'filtering'
do
context
'by search term'
do
it
'calls Ci::Runner.search'
do
expect
(
Ci
::
Runner
).
to
receive
(
:search
).
with
(
'term'
).
and_call_original
described_class
.
new
(
current_user:
admin
,
params:
{
search:
'term'
}).
execute
described_class
.
new
(
current_user:
admin
,
params:
{
search:
'term'
}).
execute
end
end
end
context
'filter
by status'
do
Ci
::
Runner
::
AVAILABLE_STATUSES
.
each
do
|
status
|
it
"calls the corresponding :
#{
status
}
scope on Ci::Runner"
do
expect
(
Ci
::
Runner
).
to
receive
(
status
.
to_sym
).
and_call_original
context
'
by status'
do
Ci
::
Runner
::
AVAILABLE_STATUSES
.
each
do
|
status
|
it
"calls the corresponding :
#{
status
}
scope on Ci::Runner"
do
expect
(
Ci
::
Runner
).
to
receive
(
status
.
to_sym
).
and_call_original
described_class
.
new
(
current_user:
admin
,
params:
{
status_status:
status
}).
execute
described_class
.
new
(
current_user:
admin
,
params:
{
status_status:
status
}).
execute
end
end
end
end
context
'filter
by runner type'
do
it
'calls the corresponding scope on Ci::Runner'
do
expect
(
Ci
::
Runner
).
to
receive
(
:project_type
).
and_call_original
context
'
by runner type'
do
it
'calls the corresponding scope on Ci::Runner'
do
expect
(
Ci
::
Runner
).
to
receive
(
:project_type
).
and_call_original
described_class
.
new
(
current_user:
admin
,
params:
{
type_type:
'project_type'
}).
execute
described_class
.
new
(
current_user:
admin
,
params:
{
type_type:
'project_type'
}).
execute
end
end
end
context
'filter
by tag_name'
do
it
'calls the corresponding scope on Ci::Runner'
do
expect
(
Ci
::
Runner
).
to
receive
(
:tagged_with
).
with
(
%w[tag1 tag2]
).
and_call_original
context
'
by tag_name'
do
it
'calls the corresponding scope on Ci::Runner'
do
expect
(
Ci
::
Runner
).
to
receive
(
:tagged_with
).
with
(
%w[tag1 tag2]
).
and_call_original
described_class
.
new
(
current_user:
admin
,
params:
{
tag_name:
%w[tag1 tag2]
}).
execute
described_class
.
new
(
current_user:
admin
,
params:
{
tag_name:
%w[tag1 tag2]
}).
execute
end
end
end
context
'sort'
do
context
'sort
ing
'
do
let_it_be
(
:runner1
)
{
create
:ci_runner
,
created_at:
'2018-07-12 07:00'
,
contacted_at:
1
.
minute
.
ago
}
let_it_be
(
:runner2
)
{
create
:ci_runner
,
created_at:
'2018-07-12 08:00'
,
contacted_at:
3
.
minutes
.
ago
}
let_it_be
(
:runner3
)
{
create
:ci_runner
,
created_at:
'2018-07-12 09:00'
,
contacted_at:
2
.
minutes
.
ago
}
...
...
@@ -121,7 +123,7 @@ RSpec.describe Ci::RunnersFinder do
end
end
context
'non admin user'
do
context
'
by
non admin user'
do
it
'returns no runners'
do
user
=
create
:user
create
:ci_runner
,
active:
true
...
...
@@ -131,7 +133,7 @@ RSpec.describe Ci::RunnersFinder do
end
end
context
'user is nil'
do
context
'
when
user is nil'
do
it
'returns no runners'
do
user
=
nil
create
:ci_runner
,
active:
true
...
...
@@ -210,57 +212,59 @@ RSpec.describe Ci::RunnersFinder do
end
end
context
'filter by search term'
do
let
(
:params
)
{
{
search:
'runner_project_search'
}
}
context
'filtering'
do
context
'by search term'
do
let
(
:params
)
{
{
search:
'runner_project_search'
}
}
before
do
group
.
add_owner
(
user
)
end
before
do
group
.
add_owner
(
user
)
end
it
'returns correct runner'
do
expect
(
subject
).
to
eq
([
runner_project_3
])
it
'returns correct runner'
do
expect
(
subject
).
to
eq
([
runner_project_3
])
end
end
end
context
'filter
by status'
do
let
(
:params
)
{
{
status_status:
'paused'
}
}
context
'
by status'
do
let
(
:params
)
{
{
status_status:
'paused'
}
}
before
do
group
.
add_owner
(
user
)
end
before
do
group
.
add_owner
(
user
)
end
it
'returns correct runner'
do
expect
(
subject
).
to
eq
([
runner_sub_group_1
])
it
'returns correct runner'
do
expect
(
subject
).
to
eq
([
runner_sub_group_1
])
end
end
end
context
'filter
by tag_name'
do
let
(
:params
)
{
{
tag_name:
%w[runner_tag]
}
}
context
'
by tag_name'
do
let
(
:params
)
{
{
tag_name:
%w[runner_tag]
}
}
before
do
group
.
add_owner
(
user
)
end
before
do
group
.
add_owner
(
user
)
end
it
'returns correct runner'
do
expect
(
subject
).
to
eq
([
runner_project_5
])
it
'returns correct runner'
do
expect
(
subject
).
to
eq
([
runner_project_5
])
end
end
end
context
'filter
by runner type'
do
let
(
:params
)
{
{
type_type:
'project_type'
}
}
context
'
by runner type'
do
let
(
:params
)
{
{
type_type:
'project_type'
}
}
before
do
group
.
add_owner
(
user
)
end
before
do
group
.
add_owner
(
user
)
end
it
'returns correct runners'
do
expect
(
subject
).
to
eq
([
runner_project_7
,
runner_project_6
,
runner_project_5
,
runner_project_4
,
runner_project_3
,
runner_project_2
,
runner_project_1
])
it
'returns correct runners'
do
expect
(
subject
).
to
eq
([
runner_project_7
,
runner_project_6
,
runner_project_5
,
runner_project_4
,
runner_project_3
,
runner_project_2
,
runner_project_1
])
end
end
end
context
'
user has no access to runners
'
do
context
'
when user is not group owner
'
do
where
(
:user_permission
)
do
[
:maintainer
,
:developer
,
:reporter
,
:guest
]
end
...
...
@@ -276,13 +280,13 @@ RSpec.describe Ci::RunnersFinder do
end
end
context
'
user with
no access'
do
context
'
when user has
no access'
do
it
'returns no runners'
do
expect
(
subject
).
to
be_empty
end
end
context
'user is nil'
do
context
'
when
user is nil'
do
let_it_be
(
:user
)
{
nil
}
it
'returns no runners'
do
...
...
@@ -294,7 +298,7 @@ RSpec.describe Ci::RunnersFinder do
describe
'#sort_key'
do
subject
{
described_class
.
new
(
current_user:
user
,
group:
group
,
params:
params
).
sort_key
}
context
'
no
params'
do
context
'
without
params'
do
it
'returns created_at_desc'
do
expect
(
subject
).
to
eq
(
'created_at_desc'
)
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