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
72ee101f
Commit
72ee101f
authored
Mar 24, 2020
by
Lucas Charles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
De-duplicate jobs controller EE specs
Part of
https://gitlab.com/gitlab-org/gitlab/-/issues/211887
parent
c4c22b06
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
135 deletions
+118
-135
.rubocop.yml
.rubocop.yml
+0
-2
ee/spec/controllers/ee/projects/jobs_controller_spec.rb
ee/spec/controllers/ee/projects/jobs_controller_spec.rb
+118
-0
ee/spec/controllers/projects/jobs_controller_spec.rb
ee/spec/controllers/projects/jobs_controller_spec.rb
+0
-133
No files found.
.rubocop.yml
View file @
72ee101f
...
...
@@ -202,7 +202,6 @@ GitlabSecurity/PublicSend:
Gitlab/DuplicateSpecLocation
:
Exclude
:
-
ee/spec/controllers/projects/jobs_controller_spec.rb
-
ee/spec/helpers/auth_helper_spec.rb
-
ee/spec/lib/gitlab/gl_repository_spec.rb
-
ee/spec/lib/gitlab/usage_data_spec.rb
...
...
@@ -214,7 +213,6 @@ Gitlab/DuplicateSpecLocation:
-
ee/spec/services/merge_requests/refresh_service_spec.rb
-
ee/spec/services/merge_requests/update_service_spec.rb
-
ee/spec/services/system_hooks_service_spec.rb
-
ee/spec/controllers/ee/projects/jobs_controller_spec.rb
-
ee/spec/helpers/ee/auth_helper_spec.rb
-
ee/spec/lib/ee/gitlab/gl_repository_spec.rb
-
ee/spec/lib/ee/gitlab/usage_data_spec.rb
...
...
ee/spec/controllers/ee/projects/jobs_controller_spec.rb
View file @
72ee101f
...
...
@@ -157,6 +157,124 @@ describe Projects::JobsController do
end
end
describe
'GET #show'
,
:clean_gitlab_redis_shared_state
do
context
'when requesting JSON'
do
context
'with shared runner that has quota'
do
let
(
:project
)
{
create
(
:project
,
:private
,
shared_runners_enabled:
true
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
,
description:
'Shared runner'
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
runner:
runner
)
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
allow_next_instance_of
(
Ci
::
Build
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:merge_request
).
and_return
(
merge_request
)
end
stub_application_setting
(
shared_runners_minutes:
2
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'exposes quota information'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
,
dir:
'ee'
)
expect
(
json_response
[
'runners'
][
'quota'
][
'used'
]).
to
eq
0
expect
(
json_response
[
'runners'
][
'quota'
][
'limit'
]).
to
eq
2
end
end
context
'with shared runner quota exceeded'
do
let
(
:group
)
{
create
(
:group
,
:with_used_build_minutes_limit
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
group
,
shared_runners_enabled:
true
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
,
description:
'Shared runner'
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
runner:
runner
)
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'exposes quota information'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
,
dir:
'ee'
)
expect
(
json_response
[
'runners'
][
'quota'
][
'used'
]).
to
eq
1000
expect
(
json_response
[
'runners'
][
'quota'
][
'limit'
]).
to
eq
500
end
end
context
'when shared runner has no quota'
do
let
(
:project
)
{
create
(
:project
,
:private
,
shared_runners_enabled:
true
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
,
description:
'Shared runner'
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
runner:
runner
)
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
allow_next_instance_of
(
Ci
::
Build
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:merge_request
).
and_return
(
merge_request
)
end
stub_application_setting
(
shared_runners_minutes:
0
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'does not exposes quota information'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
,
dir:
'ee'
)
expect
(
json_response
[
'runners'
]).
not_to
have_key
(
'quota'
)
end
end
context
'when project is public'
do
let
(
:project
)
{
create
(
:project
,
:public
,
shared_runners_enabled:
true
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
,
description:
'Shared runner'
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
runner:
runner
)
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
allow_next_instance_of
(
Ci
::
Build
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:merge_request
).
and_return
(
merge_request
)
end
stub_application_setting
(
shared_runners_minutes:
2
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'does not exposes quota information'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
,
dir:
'ee'
)
expect
(
json_response
[
'runners'
]).
not_to
have_key
(
'quota'
)
end
end
end
private
def
get_show
(
**
extra_params
)
params
=
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
}
get
:show
,
params:
params
.
merge
(
extra_params
)
end
end
describe
'GET #proxy_websocket_authorize'
do
let
(
:path
)
{
:proxy_websocket_authorize
}
let
(
:render_method
)
{
:channel_websocket
}
...
...
ee/spec/controllers/projects/jobs_controller_spec.rb
deleted
100644 → 0
View file @
c4c22b06
# frozen_string_literal: true
require
'spec_helper'
describe
Projects
::
JobsController
,
:clean_gitlab_redis_shared_state
do
include
ApiHelpers
include
HttpIOHelpers
let
(
:user
)
{
create
(
:user
)
}
before
do
stub_not_protect_default_branch
end
describe
'GET show'
do
context
'when requesting JSON'
do
context
'with shared runner that has quota'
do
let
(
:project
)
{
create
(
:project
,
:private
,
shared_runners_enabled:
true
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
,
description:
'Shared runner'
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
runner:
runner
)
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
allow_next_instance_of
(
Ci
::
Build
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:merge_request
).
and_return
(
merge_request
)
end
stub_application_setting
(
shared_runners_minutes:
2
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'exposes quota information'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
,
dir:
'ee'
)
expect
(
json_response
[
'runners'
][
'quota'
][
'used'
]).
to
eq
0
expect
(
json_response
[
'runners'
][
'quota'
][
'limit'
]).
to
eq
2
end
end
context
'with shared runner quota exceeded'
do
let
(
:group
)
{
create
(
:group
,
:with_used_build_minutes_limit
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
group
,
shared_runners_enabled:
true
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
,
description:
'Shared runner'
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
runner:
runner
)
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'exposes quota information'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
,
dir:
'ee'
)
expect
(
json_response
[
'runners'
][
'quota'
][
'used'
]).
to
eq
1000
expect
(
json_response
[
'runners'
][
'quota'
][
'limit'
]).
to
eq
500
end
end
context
'when shared runner has no quota'
do
let
(
:project
)
{
create
(
:project
,
:private
,
shared_runners_enabled:
true
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
,
description:
'Shared runner'
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
runner:
runner
)
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
allow_next_instance_of
(
Ci
::
Build
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:merge_request
).
and_return
(
merge_request
)
end
stub_application_setting
(
shared_runners_minutes:
0
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'does not exposes quota information'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
,
dir:
'ee'
)
expect
(
json_response
[
'runners'
]).
not_to
have_key
(
'quota'
)
end
end
context
'when project is public'
do
let
(
:project
)
{
create
(
:project
,
:public
,
shared_runners_enabled:
true
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
,
description:
'Shared runner'
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
runner:
runner
)
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
allow_next_instance_of
(
Ci
::
Build
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:merge_request
).
and_return
(
merge_request
)
end
stub_application_setting
(
shared_runners_minutes:
2
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'does not exposes quota information'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
,
dir:
'ee'
)
expect
(
json_response
[
'runners'
]).
not_to
have_key
(
'quota'
)
end
end
end
private
def
get_show
(
**
extra_params
)
params
=
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
}
get
:show
,
params:
params
.
merge
(
extra_params
)
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