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
684d6531
Commit
684d6531
authored
Apr 02, 2020
by
GitLab Bot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest changes from gitlab-org/gitlab@master
parent
ade18c9d
Changes
59
Hide whitespace changes
Inline
Side-by-side
Showing
59 changed files
with
754 additions
and
320 deletions
+754
-320
.rubocop.yml
.rubocop.yml
+0
-4
app/assets/javascripts/blob/blob_file_dropzone.js
app/assets/javascripts/blob/blob_file_dropzone.js
+4
-0
app/controllers/groups/group_members_controller.rb
app/controllers/groups/group_members_controller.rb
+1
-1
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-1
app/finders/group_members_finder.rb
app/finders/group_members_finder.rb
+6
-3
app/serializers/diffs_entity.rb
app/serializers/diffs_entity.rb
+28
-6
app/services/concerns/deploy_token_methods.rb
app/services/concerns/deploy_token_methods.rb
+6
-0
app/services/groups/deploy_tokens/destroy_service.rb
app/services/groups/deploy_tokens/destroy_service.rb
+13
-0
app/services/projects/deploy_tokens/destroy_service.rb
app/services/projects/deploy_tokens/destroy_service.rb
+13
-0
app/services/resource_events/synthetic_milestone_notes_builder_service.rb
...ource_events/synthetic_milestone_notes_builder_service.rb
+0
-6
app/workers/gitlab/github_import/advance_stage_worker.rb
app/workers/gitlab/github_import/advance_stage_worker.rb
+4
-0
app/workers/gitlab/import/advance_stage.rb
app/workers/gitlab/import/advance_stage.rb
+1
-1
app/workers/gitlab/jira_import/advance_stage_worker.rb
app/workers/gitlab/jira_import/advance_stage_worker.rb
+4
-0
changelogs/unreleased/212523-delete-deploy-tokens.yml
changelogs/unreleased/212523-delete-deploy-tokens.yml
+5
-0
changelogs/unreleased/212985-remove-ff-check-for-synthetic-milestone-notes-creation.yml
...emove-ff-check-for-synthetic-milestone-notes-creation.yml
+5
-0
changelogs/unreleased/42639-remove-custom-metrics-license-check.yml
.../unreleased/42639-remove-custom-metrics-license-check.yml
+5
-0
changelogs/unreleased/merge-request-typo.yml
changelogs/unreleased/merge-request-typo.yml
+5
-0
changelogs/unreleased/ph-212642-userUploadsFile.yml
changelogs/unreleased/ph-212642-userUploadsFile.yml
+5
-0
changelogs/unreleased/refactor-ability-spec.yml
changelogs/unreleased/refactor-ability-spec.yml
+5
-0
changelogs/unreleased/refactor-build-spec.yml
changelogs/unreleased/refactor-build-spec.yml
+5
-0
changelogs/unreleased/separate-validator-files.yml
changelogs/unreleased/separate-validator-files.yml
+5
-0
config/initializers/grape_validators.rb
config/initializers/grape_validators.rb
+9
-0
doc/development/migration_style_guide.md
doc/development/migration_style_guide.md
+1
-0
lib/api/deploy_tokens.rb
lib/api/deploy_tokens.rb
+10
-8
lib/api/entities/commit_with_link.rb
lib/api/entities/commit_with_link.rb
+8
-0
lib/api/environments.rb
lib/api/environments.rb
+0
-1
lib/api/helpers.rb
lib/api/helpers.rb
+4
-2
lib/api/helpers/merge_requests_helpers.rb
lib/api/helpers/merge_requests_helpers.rb
+0
-1
lib/api/issues.rb
lib/api/issues.rb
+1
-1
lib/api/validations/check_assignees_count.rb
lib/api/validations/check_assignees_count.rb
+0
-34
lib/api/validations/validators/absence.rb
lib/api/validations/validators/absence.rb
+15
-0
lib/api/validations/validators/array_none_any.rb
lib/api/validations/validators/array_none_any.rb
+19
-0
lib/api/validations/validators/check_assignees_count.rb
lib/api/validations/validators/check_assignees_count.rb
+36
-0
lib/api/validations/validators/file_path.rb
lib/api/validations/validators/file_path.rb
+18
-0
lib/api/validations/validators/git_ref.rb
lib/api/validations/validators/git_ref.rb
+36
-0
lib/api/validations/validators/git_sha.rb
lib/api/validations/validators/git_sha.rb
+18
-0
lib/api/validations/validators/integer_none_any.rb
lib/api/validations/validators/integer_none_any.rb
+19
-0
spec/controllers/projects/issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+20
-0
spec/features/projects/files/user_uploads_files_spec.rb
spec/features/projects/files/user_uploads_files_spec.rb
+25
-0
spec/finders/group_members_finder_spec.rb
spec/finders/group_members_finder_spec.rb
+5
-5
spec/frontend/diffs/components/commit_item_spec.js
spec/frontend/diffs/components/commit_item_spec.js
+10
-15
spec/lib/api/helpers/custom_validators_spec.rb
spec/lib/api/helpers/custom_validators_spec.rb
+0
-193
spec/lib/api/validations/validators/absence_spec.rb
spec/lib/api/validations/validators/absence_spec.rb
+23
-0
spec/lib/api/validations/validators/array_none_any_spec.rb
spec/lib/api/validations/validators/array_none_any_spec.rb
+28
-0
spec/lib/api/validations/validators/file_path_spec.rb
spec/lib/api/validations/validators/file_path_spec.rb
+36
-0
spec/lib/api/validations/validators/git_ref_spec.rb
spec/lib/api/validations/validators/git_ref_spec.rb
+46
-0
spec/lib/api/validations/validators/git_sha_spec.rb
spec/lib/api/validations/validators/git_sha_spec.rb
+37
-0
spec/lib/api/validations/validators/integer_none_any_spec.rb
spec/lib/api/validations/validators/integer_none_any_spec.rb
+28
-0
spec/lib/banzai/filter/autolink_filter_spec.rb
spec/lib/banzai/filter/autolink_filter_spec.rb
+0
-5
spec/lib/gitlab/git/blob_spec.rb
spec/lib/gitlab/git/blob_spec.rb
+24
-18
spec/models/ability_spec.rb
spec/models/ability_spec.rb
+0
-6
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-1
spec/requests/api/deploy_tokens_spec.rb
spec/requests/api/deploy_tokens_spec.rb
+22
-8
spec/serializers/diffs_entity_spec.rb
spec/serializers/diffs_entity_spec.rb
+42
-0
spec/services/groups/deploy_tokens/destroy_service_spec.rb
spec/services/groups/deploy_tokens/destroy_service_spec.rb
+11
-0
spec/services/projects/deploy_tokens/destroy_service_spec.rb
spec/services/projects/deploy_tokens/destroy_service_spec.rb
+11
-0
spec/services/resource_events/synthetic_milestone_notes_builder_service_spec.rb
..._events/synthetic_milestone_notes_builder_service_spec.rb
+25
-0
spec/support/helpers/api_validators_helpers.rb
spec/support/helpers/api_validators_helpers.rb
+23
-0
spec/support/services/deploy_token_shared_examples.rb
spec/support/services/deploy_token_shared_examples.rb
+22
-0
No files found.
.rubocop.yml
View file @
684d6531
...
@@ -401,13 +401,9 @@ RSpec/RepeatedExample:
...
@@ -401,13 +401,9 @@ RSpec/RepeatedExample:
-
'
spec/frontend/fixtures/merge_requests.rb'
-
'
spec/frontend/fixtures/merge_requests.rb'
-
'
spec/graphql/gitlab_schema_spec.rb'
-
'
spec/graphql/gitlab_schema_spec.rb'
-
'
spec/helpers/users_helper_spec.rb'
-
'
spec/helpers/users_helper_spec.rb'
-
'
spec/lib/banzai/filter/autolink_filter_spec.rb'
-
'
spec/lib/gitlab/closing_issue_extractor_spec.rb'
-
'
spec/lib/gitlab/closing_issue_extractor_spec.rb'
-
'
spec/lib/gitlab/danger/changelog_spec.rb'
-
'
spec/lib/gitlab/danger/changelog_spec.rb'
-
'
spec/lib/gitlab/git/blob_spec.rb'
-
'
spec/lib/gitlab/import_export/project/relation_factory_spec.rb'
-
'
spec/lib/gitlab/import_export/project/relation_factory_spec.rb'
-
'
spec/models/ability_spec.rb'
-
'
spec/models/ci/build_spec.rb'
-
'
spec/models/concerns/issuable_spec.rb'
-
'
spec/models/concerns/issuable_spec.rb'
-
'
spec/models/project_services/chat_message/pipeline_message_spec.rb'
-
'
spec/models/project_services/chat_message/pipeline_message_spec.rb'
-
'
spec/routing/admin_routing_spec.rb'
-
'
spec/routing/admin_routing_spec.rb'
...
...
app/assets/javascripts/blob/blob_file_dropzone.js
View file @
684d6531
...
@@ -43,6 +43,10 @@ export default class BlobFileDropzone {
...
@@ -43,6 +43,10 @@ export default class BlobFileDropzone {
previewsContainer
:
'
.dropzone-previews
'
,
previewsContainer
:
'
.dropzone-previews
'
,
headers
:
csrf
.
headers
,
headers
:
csrf
.
headers
,
init
()
{
init
()
{
this
.
on
(
'
processing
'
,
function
()
{
this
.
options
.
url
=
form
.
attr
(
'
action
'
);
});
this
.
on
(
'
addedfile
'
,
()
=>
{
this
.
on
(
'
addedfile
'
,
()
=>
{
toggleLoading
(
submitButton
,
submitButtonLoadingIcon
,
false
);
toggleLoading
(
submitButton
,
submitButtonLoadingIcon
,
false
);
dropzoneMessage
.
addClass
(
HIDDEN_CLASS
);
dropzoneMessage
.
addClass
(
HIDDEN_CLASS
);
...
...
app/controllers/groups/group_members_controller.rb
View file @
684d6531
...
@@ -57,7 +57,7 @@ class Groups::GroupMembersController < Groups::ApplicationController
...
@@ -57,7 +57,7 @@ class Groups::GroupMembersController < Groups::ApplicationController
def
find_members
def
find_members
filter_params
=
params
.
slice
(
:two_factor
,
:search
).
merge
(
sort:
@sort
)
filter_params
=
params
.
slice
(
:two_factor
,
:search
).
merge
(
sort:
@sort
)
GroupMembersFinder
.
new
(
@group
,
current_user
).
execute
(
include_relations:
requested_relations
,
params:
filter_param
s
)
GroupMembersFinder
.
new
(
@group
,
current_user
,
params:
filter_params
).
execute
(
include_relations:
requested_relation
s
)
end
end
def
can_manage_members
def
can_manage_members
...
...
app/controllers/projects/issues_controller.rb
View file @
684d6531
...
@@ -186,7 +186,7 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -186,7 +186,7 @@ class Projects::IssuesController < Projects::ApplicationController
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
render
json:
MergeRequestCreateSerializer
.
new
.
represent
(
result
[
:merge_request
])
render
json:
MergeRequestCreateSerializer
.
new
.
represent
(
result
[
:merge_request
])
else
else
render
json:
result
[
:mess
s
age
],
status: :unprocessable_entity
render
json:
result
[
:message
],
status: :unprocessable_entity
end
end
end
end
...
...
app/finders/group_members_finder.rb
View file @
684d6531
...
@@ -10,13 +10,16 @@ class GroupMembersFinder < UnionFinder
...
@@ -10,13 +10,16 @@ class GroupMembersFinder < UnionFinder
# created_after: datetime
# created_after: datetime
# created_before: datetime
# created_before: datetime
def
initialize
(
group
,
user
=
nil
)
attr_reader
:params
def
initialize
(
group
,
user
=
nil
,
params:
{})
@group
=
group
@group
=
group
@user
=
user
@user
=
user
@params
=
params
end
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
execute
(
include_relations:
[
:inherited
,
:direct
]
,
params:
{}
)
def
execute
(
include_relations:
[
:inherited
,
:direct
])
group_members
=
group
.
members
group_members
=
group
.
members
relations
=
[]
relations
=
[]
@params
=
params
@params
=
params
...
@@ -50,7 +53,7 @@ class GroupMembersFinder < UnionFinder
...
@@ -50,7 +53,7 @@ class GroupMembersFinder < UnionFinder
private
private
attr_reader
:user
,
:group
,
:params
attr_reader
:user
,
:group
def
filter_members
(
members
)
def
filter_members
(
members
)
members
=
members
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
members
=
members
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
...
...
app/serializers/diffs_entity.rb
View file @
684d6531
...
@@ -16,12 +16,7 @@ class DiffsEntity < Grape::Entity
...
@@ -16,12 +16,7 @@ class DiffsEntity < Grape::Entity
end
end
expose
:commit
do
|
diffs
,
options
|
expose
:commit
do
|
diffs
,
options
|
CommitEntity
.
represent
options
[
:commit
],
options
.
merge
(
CommitEntity
.
represent
(
options
[
:commit
],
commit_options
(
options
))
type: :full
,
commit_url_params:
{
merge_request_iid:
merge_request
&
.
iid
},
pipeline_ref:
merge_request
&
.
source_branch
,
pipeline_project:
merge_request
&
.
source_project
)
end
end
expose
:context_commits
,
using:
API
::
Entities
::
Commit
,
if:
->
(
diffs
,
options
)
{
merge_request
&
.
project
&
.
context_commits_enabled?
}
do
|
diffs
|
expose
:context_commits
,
using:
API
::
Entities
::
Commit
,
if:
->
(
diffs
,
options
)
{
merge_request
&
.
project
&
.
context_commits_enabled?
}
do
|
diffs
|
...
@@ -88,4 +83,31 @@ class DiffsEntity < Grape::Entity
...
@@ -88,4 +83,31 @@ class DiffsEntity < Grape::Entity
def
merge_request
def
merge_request
options
[
:merge_request
]
options
[
:merge_request
]
end
end
private
def
commit_ids
@commit_ids
||=
merge_request
.
recent_commits
.
map
(
&
:id
)
end
def
commit_neighbors
(
commit_id
)
index
=
commit_ids
.
index
(
commit_id
)
return
[]
unless
index
[(
index
>
0
?
commit_ids
[
index
-
1
]
:
nil
),
commit_ids
[
index
+
1
]]
end
def
commit_options
(
options
)
prev_commit_id
,
next_commit_id
=
*
commit_neighbors
(
options
[
:commit
]
&
.
id
)
options
.
merge
(
type: :full
,
commit_url_params:
{
merge_request_iid:
merge_request
&
.
iid
},
pipeline_ref:
merge_request
&
.
source_branch
,
pipeline_project:
merge_request
&
.
source_project
,
prev_commit_id:
prev_commit_id
,
next_commit_id:
next_commit_id
)
end
end
end
app/services/concerns/deploy_token_methods.rb
View file @
684d6531
...
@@ -8,4 +8,10 @@ module DeployTokenMethods
...
@@ -8,4 +8,10 @@ module DeployTokenMethods
deploy_token
.
username
=
params
[
:username
].
presence
deploy_token
.
username
=
params
[
:username
].
presence
end
end
end
end
def
destroy_deploy_token
(
entity
,
params
)
deploy_token
=
entity
.
deploy_tokens
.
find_by_id!
(
params
[
:token_id
])
deploy_token
.
destroy
end
end
end
app/services/groups/deploy_tokens/destroy_service.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
module
Groups
module
DeployTokens
class
DestroyService
<
BaseService
include
DeployTokenMethods
def
execute
destroy_deploy_token
(
@group
,
params
)
end
end
end
end
app/services/projects/deploy_tokens/destroy_service.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
module
Projects
module
DeployTokens
class
DestroyService
<
BaseService
include
DeployTokenMethods
def
execute
destroy_deploy_token
(
@project
,
params
)
end
end
end
end
app/services/resource_events/synthetic_milestone_notes_builder_service.rb
View file @
684d6531
...
@@ -10,8 +10,6 @@ module ResourceEvents
...
@@ -10,8 +10,6 @@ module ResourceEvents
private
private
def
synthetic_notes
def
synthetic_notes
return
[]
unless
tracking_enabled?
milestone_change_events
.
map
do
|
event
|
milestone_change_events
.
map
do
|
event
|
MilestoneNote
.
from_event
(
event
,
resource:
resource
,
resource_parent:
resource_parent
)
MilestoneNote
.
from_event
(
event
,
resource:
resource
,
resource_parent:
resource_parent
)
end
end
...
@@ -23,9 +21,5 @@ module ResourceEvents
...
@@ -23,9 +21,5 @@ module ResourceEvents
events
=
resource
.
resource_milestone_events
.
includes
(
user: :status
)
# rubocop: disable CodeReuse/ActiveRecord
events
=
resource
.
resource_milestone_events
.
includes
(
user: :status
)
# rubocop: disable CodeReuse/ActiveRecord
since_fetch_at
(
events
)
since_fetch_at
(
events
)
end
end
def
tracking_enabled?
::
Feature
.
enabled?
(
:track_resource_milestone_change_events
,
resource
.
project
)
end
end
end
end
end
app/workers/gitlab/github_import/advance_stage_worker.rb
View file @
684d6531
...
@@ -21,6 +21,10 @@ module Gitlab
...
@@ -21,6 +21,10 @@ module Gitlab
finish:
Stage
::
FinishImportWorker
finish:
Stage
::
FinishImportWorker
}.
freeze
}.
freeze
def
find_import_state
(
project_id
)
ProjectImportState
.
jid_by
(
project_id:
project_id
,
status: :started
)
end
private
private
def
next_stage_worker
(
next_stage
)
def
next_stage_worker
(
next_stage
)
...
...
app/workers/gitlab/import/advance_stage.rb
View file @
684d6531
...
@@ -48,7 +48,7 @@ module Gitlab
...
@@ -48,7 +48,7 @@ module Gitlab
end
end
def
find_import_state
(
project_id
)
def
find_import_state
(
project_id
)
ProjectImportState
.
jid_by
(
project_id:
project_id
,
status: :started
)
raise
NotImplementedError
end
end
private
private
...
...
app/workers/gitlab/jira_import/advance_stage_worker.rb
View file @
684d6531
...
@@ -16,6 +16,10 @@ module Gitlab
...
@@ -16,6 +16,10 @@ module Gitlab
finish:
Gitlab
::
JiraImport
::
Stage
::
FinishImportWorker
finish:
Gitlab
::
JiraImport
::
Stage
::
FinishImportWorker
}.
freeze
}.
freeze
def
find_import_state
(
project_id
)
ProjectImportState
.
jid_by
(
project_id:
project_id
,
status: :started
)
end
private
private
def
next_stage_worker
(
next_stage
)
def
next_stage_worker
(
next_stage
)
...
...
changelogs/unreleased/212523-delete-deploy-tokens.yml
0 → 100644
View file @
684d6531
---
title
:
Fix deploy token API to properly delete all associated deploy token records
merge_request
:
28156
author
:
type
:
fixed
changelogs/unreleased/212985-remove-ff-check-for-synthetic-milestone-notes-creation.yml
0 → 100644
View file @
684d6531
---
title
:
Fix missing synthetic milestone change notes for disabled milestone change event tracking feature flag
merge_request
:
28440
author
:
type
:
fixed
changelogs/unreleased/42639-remove-custom-metrics-license-check.yml
0 → 100644
View file @
684d6531
---
title
:
Move 'Additional Metrics' feature to GitLab Core
merge_request
:
28527
author
:
type
:
changed
changelogs/unreleased/merge-request-typo.yml
0 → 100644
View file @
684d6531
---
title
:
Return error message for create_merge_request
merge_request
:
28482
author
:
type
:
fixed
changelogs/unreleased/ph-212642-userUploadsFile.yml
0 → 100644
View file @
684d6531
---
title
:
Fixed upload file creating a file in the wrong directory
merge_request
:
author
:
type
:
fixed
changelogs/unreleased/refactor-ability-spec.yml
0 → 100644
View file @
684d6531
---
title
:
Remove duplicate specs in ability model
merge_request
:
28644
author
:
Rajendra Kadam
type
:
added
changelogs/unreleased/refactor-build-spec.yml
0 → 100644
View file @
684d6531
---
title
:
Fix build duplicate spec
merge_request
:
28633
author
:
Rajendra Kadam
type
:
added
changelogs/unreleased/separate-validator-files.yml
0 → 100644
View file @
684d6531
---
title
:
Separate validators into own class files
merge_request
:
28266
author
:
Rajendra Kadam
type
:
added
config/initializers/grape_validators.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
Grape
::
Validations
.
register_validator
(
:absence
,
::
API
::
Validations
::
Validators
::
Absence
)
Grape
::
Validations
.
register_validator
(
:file_path
,
::
API
::
Validations
::
Validators
::
FilePath
)
Grape
::
Validations
.
register_validator
(
:git_ref
,
::
API
::
Validations
::
Validators
::
GitRef
)
Grape
::
Validations
.
register_validator
(
:git_sha
,
::
API
::
Validations
::
Validators
::
GitSha
)
Grape
::
Validations
.
register_validator
(
:integer_none_any
,
::
API
::
Validations
::
Validators
::
IntegerNoneAny
)
Grape
::
Validations
.
register_validator
(
:array_none_any
,
::
API
::
Validations
::
Validators
::
ArrayNoneAny
)
Grape
::
Validations
.
register_validator
(
:check_assignees_count
,
::
API
::
Validations
::
Validators
::
CheckAssigneesCount
)
doc/development/migration_style_guide.md
View file @
684d6531
...
@@ -246,6 +246,7 @@ Example changes:
...
@@ -246,6 +246,7 @@ Example changes:
-
`add_foreign_key`
/
`remove_foreign_key`
-
`add_foreign_key`
/
`remove_foreign_key`
-
`add_column`
/
`remove_column`
-
`add_column`
/
`remove_column`
-
`change_column_default`
-
`change_column_default`
-
`create_table`
/
`drop_table`
**Note:**
`with_lock_retries`
method
**cannot**
be used with
`disable_ddl_transaction!`
.
**Note:**
`with_lock_retries`
method
**cannot**
be used with
`disable_ddl_transaction!`
.
...
...
lib/api/deploy_tokens.rb
View file @
684d6531
...
@@ -85,12 +85,10 @@ module API
...
@@ -85,12 +85,10 @@ module API
delete
':id/deploy_tokens/:token_id'
do
delete
':id/deploy_tokens/:token_id'
do
authorize!
(
:destroy_deploy_token
,
user_project
)
authorize!
(
:destroy_deploy_token
,
user_project
)
deploy_token
=
user_project
.
project_deploy_tokens
::
Projects
::
DeployTokens
::
DestroyService
.
new
(
.
find_by_deploy_token_id
(
params
[
:token_id
])
user_project
,
current_user
,
token_id:
params
[
:token_id
]
).
execute
not_found!
(
'Deploy Token'
)
unless
deploy_token
deploy_token
.
destroy
no_content!
no_content!
end
end
end
end
...
@@ -144,13 +142,17 @@ module API
...
@@ -144,13 +142,17 @@ module API
desc
'Delete a group deploy token'
do
desc
'Delete a group deploy token'
do
detail
'This feature was introduced in GitLab 12.9'
detail
'This feature was introduced in GitLab 12.9'
end
end
params
do
requires
:token_id
,
type:
Integer
,
desc:
'The deploy token ID'
end
delete
':id/deploy_tokens/:token_id'
do
delete
':id/deploy_tokens/:token_id'
do
authorize!
(
:destroy_deploy_token
,
user_group
)
authorize!
(
:destroy_deploy_token
,
user_group
)
deploy_token
=
user_group
.
group_deploy_tokens
::
Groups
::
DeployTokens
::
DestroyService
.
new
(
.
find_by_deploy_token_id!
(
params
[
:token_id
])
user_group
,
current_user
,
token_id:
params
[
:token_id
]
).
execute
destroy_conditionally!
(
deploy_token
)
no_content!
end
end
end
end
end
end
...
...
lib/api/entities/commit_with_link.rb
View file @
684d6531
...
@@ -32,6 +32,14 @@ module API
...
@@ -32,6 +32,14 @@ module API
render
(
'projects/commit/_signature'
,
signature:
commit
.
signature
)
if
commit
.
has_signature?
render
(
'projects/commit/_signature'
,
signature:
commit
.
signature
)
if
commit
.
has_signature?
end
end
expose
:prev_commit_id
,
if:
{
type: :full
}
do
|
commit
|
options
[
:prev_commit_id
]
end
expose
:next_commit_id
,
if:
{
type: :full
}
do
|
commit
|
options
[
:next_commit_id
]
end
expose
:pipeline_status_path
,
if:
{
type: :full
}
do
|
commit
,
options
|
expose
:pipeline_status_path
,
if:
{
type: :full
}
do
|
commit
,
options
|
pipeline_ref
=
options
[
:pipeline_ref
]
pipeline_ref
=
options
[
:pipeline_ref
]
pipeline_project
=
options
[
:pipeline_project
]
||
commit
.
project
pipeline_project
=
options
[
:pipeline_project
]
||
commit
.
project
...
...
lib/api/environments.rb
View file @
684d6531
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
module
API
module
API
# Environments RESTfull API endpoints
# Environments RESTfull API endpoints
class
Environments
<
Grape
::
API
class
Environments
<
Grape
::
API
include
::
API
::
Helpers
::
CustomValidators
include
PaginationParams
include
PaginationParams
before
{
authenticate!
}
before
{
authenticate!
}
...
...
lib/api/helpers.rb
View file @
684d6531
...
@@ -179,8 +179,10 @@ module API
...
@@ -179,8 +179,10 @@ module API
end
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
find_project_issue
(
iid
)
def
find_project_issue
(
iid
,
project_id
=
nil
)
IssuesFinder
.
new
(
current_user
,
project_id:
user_project
.
id
).
find_by!
(
iid:
iid
)
project
=
project_id
?
find_project!
(
project_id
)
:
user_project
::
IssuesFinder
.
new
(
current_user
,
project_id:
project
.
id
).
find_by!
(
iid:
iid
)
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
...
...
lib/api/helpers/merge_requests_helpers.rb
View file @
684d6531
...
@@ -4,7 +4,6 @@ module API
...
@@ -4,7 +4,6 @@ module API
module
Helpers
module
Helpers
module
MergeRequestsHelpers
module
MergeRequestsHelpers
extend
Grape
::
API
::
Helpers
extend
Grape
::
API
::
Helpers
include
::
API
::
Helpers
::
CustomValidators
params
:merge_requests_base_params
do
params
:merge_requests_base_params
do
optional
:state
,
optional
:state
,
...
...
lib/api/issues.rb
View file @
684d6531
...
@@ -23,7 +23,7 @@ module API
...
@@ -23,7 +23,7 @@ module API
optional
:assignee_id
,
types:
[
Integer
,
String
],
integer_none_any:
true
,
optional
:assignee_id
,
types:
[
Integer
,
String
],
integer_none_any:
true
,
desc:
'Return issues which are assigned to the user with the given ID'
desc:
'Return issues which are assigned to the user with the given ID'
optional
:assignee_username
,
type:
Array
[
String
],
check_assignees_count:
true
,
optional
:assignee_username
,
type:
Array
[
String
],
check_assignees_count:
true
,
coerce_with:
Validations
::
CheckAssigneesCount
.
coerce
,
coerce_with:
Validations
::
Validators
::
CheckAssigneesCount
.
coerce
,
desc:
'Return issues which are assigned to the user with the given username'
desc:
'Return issues which are assigned to the user with the given username'
mutually_exclusive
:assignee_id
,
:assignee_username
mutually_exclusive
:assignee_id
,
:assignee_username
end
end
...
...
lib/api/validations/check_assignees_count.rb
deleted
100644 → 0
View file @
ade18c9d
# frozen_string_literal: true
module
API
module
Validations
class
CheckAssigneesCount
<
Grape
::
Validations
::
Base
def
self
.
coerce
lambda
do
|
value
|
case
value
when
String
,
Array
Array
.
wrap
(
value
)
else
[]
end
end
end
def
validate_param!
(
attr_name
,
params
)
return
if
param_allowed?
(
attr_name
,
params
)
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
"allows one value, but found
#{
params
[
attr_name
].
size
}
:
#{
params
[
attr_name
].
join
(
", "
)
}
"
end
private
def
param_allowed?
(
attr_name
,
params
)
params
[
attr_name
].
size
<=
1
end
end
end
end
API
::
Validations
::
CheckAssigneesCount
.
prepend_if_ee
(
'EE::API::Validations::CheckAssigneesCount'
)
lib/api/validations/validators/absence.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
module
API
module
Validations
module
Validators
class
Absence
<
Grape
::
Validations
::
Base
def
validate_param!
(
attr_name
,
params
)
return
if
params
.
respond_to?
(
:key?
)
&&
!
params
.
key?
(
attr_name
)
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
message
(
:absence
)
end
end
end
end
end
lib/api/validations/validators/array_none_any.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
module
API
module
Validations
module
Validators
class
ArrayNoneAny
<
Grape
::
Validations
::
Base
def
validate_param!
(
attr_name
,
params
)
value
=
params
[
attr_name
]
return
if
value
.
is_a?
(
Array
)
||
[
IssuableFinder
::
Params
::
FILTER_NONE
,
IssuableFinder
::
Params
::
FILTER_ANY
].
include?
(
value
.
to_s
.
downcase
)
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
"should be an array, 'None' or 'Any'"
end
end
end
end
end
lib/api/validations/validators/check_assignees_count.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
module
API
module
Validations
module
Validators
class
CheckAssigneesCount
<
Grape
::
Validations
::
Base
def
self
.
coerce
lambda
do
|
value
|
case
value
when
String
,
Array
Array
.
wrap
(
value
)
else
[]
end
end
end
def
validate_param!
(
attr_name
,
params
)
return
if
param_allowed?
(
attr_name
,
params
)
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
"allows one value, but found
#{
params
[
attr_name
].
size
}
:
#{
params
[
attr_name
].
join
(
", "
)
}
"
end
private
def
param_allowed?
(
attr_name
,
params
)
params
[
attr_name
].
size
<=
1
end
end
end
end
end
API
::
Validations
::
Validators
::
CheckAssigneesCount
.
prepend_if_ee
(
'EE::API::Validations::Validators::CheckAssigneesCount'
)
lib/api/validations/validators/file_path.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
module
API
module
Validations
module
Validators
class
FilePath
<
Grape
::
Validations
::
Base
def
validate_param!
(
attr_name
,
params
)
path
=
params
[
attr_name
]
Gitlab
::
Utils
.
check_path_traversal!
(
path
)
rescue
StandardError
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
"should be a valid file path"
end
end
end
end
end
lib/api/
helpers/custom_validators
.rb
→
lib/api/
validations/validators/git_ref
.rb
View file @
684d6531
# frozen_string_literal: true
# frozen_string_literal: true
module
API
module
API
module
Helpers
module
Validations
module
CustomValidators
module
Validators
class
FilePath
<
Grape
::
Validations
::
Base
def
validate_param!
(
attr_name
,
params
)
path
=
params
[
attr_name
]
Gitlab
::
Utils
.
check_path_traversal!
(
path
)
rescue
StandardError
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
"should be a valid file path"
end
end
class
GitSha
<
Grape
::
Validations
::
Base
def
validate_param!
(
attr_name
,
params
)
sha
=
params
[
attr_name
]
return
if
Commit
::
EXACT_COMMIT_SHA_PATTERN
.
match?
(
sha
)
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
"should be a valid sha"
end
end
class
Absence
<
Grape
::
Validations
::
Base
def
validate_param!
(
attr_name
,
params
)
return
if
params
.
respond_to?
(
:key?
)
&&
!
params
.
key?
(
attr_name
)
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
message
(
:absence
)
end
end
class
IntegerNoneAny
<
Grape
::
Validations
::
Base
def
validate_param!
(
attr_name
,
params
)
value
=
params
[
attr_name
]
return
if
value
.
is_a?
(
Integer
)
||
[
IssuableFinder
::
Params
::
FILTER_NONE
,
IssuableFinder
::
Params
::
FILTER_ANY
].
include?
(
value
.
to_s
.
downcase
)
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
"should be an integer, 'None' or 'Any'"
end
end
class
ArrayNoneAny
<
Grape
::
Validations
::
Base
def
validate_param!
(
attr_name
,
params
)
value
=
params
[
attr_name
]
return
if
value
.
is_a?
(
Array
)
||
[
IssuableFinder
::
Params
::
FILTER_NONE
,
IssuableFinder
::
Params
::
FILTER_ANY
].
include?
(
value
.
to_s
.
downcase
)
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
"should be an array, 'None' or 'Any'"
end
end
class
GitRef
<
Grape
::
Validations
::
Base
class
GitRef
<
Grape
::
Validations
::
Base
# There are few checks that a Git reference should pass through to be valid reference.
# There are few checks that a Git reference should pass through to be valid reference.
# The link contains some rules that have been added to this validator.
# The link contains some rules that have been added to this validator.
...
@@ -88,10 +34,3 @@ module API
...
@@ -88,10 +34,3 @@ module API
end
end
end
end
end
end
Grape
::
Validations
.
register_validator
(
:file_path
,
::
API
::
Helpers
::
CustomValidators
::
FilePath
)
Grape
::
Validations
.
register_validator
(
:git_sha
,
::
API
::
Helpers
::
CustomValidators
::
GitSha
)
Grape
::
Validations
.
register_validator
(
:absence
,
::
API
::
Helpers
::
CustomValidators
::
Absence
)
Grape
::
Validations
.
register_validator
(
:integer_none_any
,
::
API
::
Helpers
::
CustomValidators
::
IntegerNoneAny
)
Grape
::
Validations
.
register_validator
(
:array_none_any
,
::
API
::
Helpers
::
CustomValidators
::
ArrayNoneAny
)
Grape
::
Validations
.
register_validator
(
:git_ref
,
::
API
::
Helpers
::
CustomValidators
::
GitRef
)
lib/api/validations/validators/git_sha.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
module
API
module
Validations
module
Validators
class
GitSha
<
Grape
::
Validations
::
Base
def
validate_param!
(
attr_name
,
params
)
sha
=
params
[
attr_name
]
return
if
Commit
::
EXACT_COMMIT_SHA_PATTERN
.
match?
(
sha
)
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
"should be a valid sha"
end
end
end
end
end
lib/api/validations/validators/integer_none_any.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
module
API
module
Validations
module
Validators
class
IntegerNoneAny
<
Grape
::
Validations
::
Base
def
validate_param!
(
attr_name
,
params
)
value
=
params
[
attr_name
]
return
if
value
.
is_a?
(
Integer
)
||
[
IssuableFinder
::
Params
::
FILTER_NONE
,
IssuableFinder
::
Params
::
FILTER_ANY
].
include?
(
value
.
to_s
.
downcase
)
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
"should be an integer, 'None' or 'Any'"
end
end
end
end
end
spec/controllers/projects/issues_controller_spec.rb
View file @
684d6531
...
@@ -1249,6 +1249,26 @@ describe Projects::IssuesController do
...
@@ -1249,6 +1249,26 @@ describe Projects::IssuesController do
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'invalid branch name'
do
it
'is unprocessable'
do
post
(
:create_merge_request
,
params:
{
target_project_id:
nil
,
branch_name:
'master'
,
ref:
'master'
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
issue
.
to_param
},
format: :json
)
expect
(
response
.
body
).
to
eq
(
'Branch already exists'
)
expect
(
response
).
to
have_gitlab_http_status
(
:unprocessable_entity
)
end
end
context
'target_project_id is set'
do
context
'target_project_id is set'
do
let
(
:target_project
)
{
fork_project
(
project
,
user
,
repository:
true
)
}
let
(
:target_project
)
{
fork_project
(
project
,
user
,
repository:
true
)
}
let
(
:target_project_id
)
{
target_project
.
id
}
let
(
:target_project_id
)
{
target_project
.
id
}
...
...
spec/features/projects/files/user_uploads_files_spec.rb
View file @
684d6531
...
@@ -22,6 +22,31 @@ describe 'Projects > Files > User uploads files' do
...
@@ -22,6 +22,31 @@ describe 'Projects > Files > User uploads files' do
include_examples
'it uploads and commit a new text file'
include_examples
'it uploads and commit a new text file'
include_examples
'it uploads and commit a new image file'
include_examples
'it uploads and commit a new image file'
it
'uploads a file to a sub-directory'
,
:js
do
click_link
'files'
page
.
within
(
'.repo-breadcrumb'
)
do
expect
(
page
).
to
have_content
(
'files'
)
end
find
(
'.add-to-tree'
).
click
click_link
(
'Upload file'
)
drop_in_dropzone
(
File
.
join
(
Rails
.
root
,
'spec'
,
'fixtures'
,
'doc_sample.txt'
))
page
.
within
(
'#modal-upload-blob'
)
do
fill_in
(
:commit_message
,
with:
'New commit message'
)
end
click_button
(
'Upload file'
)
expect
(
page
).
to
have_content
(
'New commit message'
)
page
.
within
(
'.repo-breadcrumb'
)
do
expect
(
page
).
to
have_content
(
'files'
)
expect
(
page
).
to
have_content
(
'doc_sample.txt'
)
end
end
end
end
context
'when a user does not have write access'
do
context
'when a user does not have write access'
do
...
...
spec/finders/group_members_finder_spec.rb
View file @
684d6531
...
@@ -82,7 +82,7 @@ describe GroupMembersFinder, '#execute' do
...
@@ -82,7 +82,7 @@ describe GroupMembersFinder, '#execute' do
group
.
add_developer
(
user3
)
group
.
add_developer
(
user3
)
member
=
group
.
add_maintainer
(
user1
)
member
=
group
.
add_maintainer
(
user1
)
result
=
described_class
.
new
(
group
).
execute
(
params:
{
search:
user1
.
name
})
result
=
described_class
.
new
(
group
,
params:
{
search:
user1
.
name
}).
execute
expect
(
result
.
to_a
).
to
match_array
([
member
])
expect
(
result
.
to_a
).
to
match_array
([
member
])
end
end
...
@@ -92,7 +92,7 @@ describe GroupMembersFinder, '#execute' do
...
@@ -92,7 +92,7 @@ describe GroupMembersFinder, '#execute' do
group
.
add_developer
(
user3
)
group
.
add_developer
(
user3
)
group
.
add_maintainer
(
user1
)
group
.
add_maintainer
(
user1
)
result
=
described_class
.
new
(
group
).
execute
(
include_relations:
[
:inherited
],
params:
{
search:
user1
.
name
}
)
result
=
described_class
.
new
(
group
,
params:
{
search:
user1
.
name
}).
execute
(
include_relations:
[
:inherited
]
)
expect
(
result
.
to_a
).
to
match_array
([])
expect
(
result
.
to_a
).
to
match_array
([])
end
end
...
@@ -103,7 +103,7 @@ describe GroupMembersFinder, '#execute' do
...
@@ -103,7 +103,7 @@ describe GroupMembersFinder, '#execute' do
nested_group
.
add_maintainer
(
create
(
:user
,
name:
user1
.
name
))
nested_group
.
add_maintainer
(
create
(
:user
,
name:
user1
.
name
))
member
=
group
.
add_maintainer
(
user1
)
member
=
group
.
add_maintainer
(
user1
)
result
=
described_class
.
new
(
nested_group
).
execute
(
include_relations:
[
:inherited
],
params:
{
search:
member
.
user
.
name
}
)
result
=
described_class
.
new
(
nested_group
,
params:
{
search:
member
.
user
.
name
}).
execute
(
include_relations:
[
:inherited
]
)
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
end
end
...
@@ -113,7 +113,7 @@ describe GroupMembersFinder, '#execute' do
...
@@ -113,7 +113,7 @@ describe GroupMembersFinder, '#execute' do
group
.
add_maintainer
(
user1
)
group
.
add_maintainer
(
user1
)
member
=
group
.
add_maintainer
(
user5
)
member
=
group
.
add_maintainer
(
user5
)
result
=
described_class
.
new
(
group
,
user2
).
execute
(
params:
{
two_factor:
'enabled'
})
result
=
described_class
.
new
(
group
,
user2
,
params:
{
two_factor:
'enabled'
}).
execute
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
end
end
...
@@ -123,7 +123,7 @@ describe GroupMembersFinder, '#execute' do
...
@@ -123,7 +123,7 @@ describe GroupMembersFinder, '#execute' do
member2
=
group
.
add_maintainer
(
user1
)
member2
=
group
.
add_maintainer
(
user1
)
member_with_2fa
=
group
.
add_maintainer
(
user5
)
member_with_2fa
=
group
.
add_maintainer
(
user5
)
result
=
described_class
.
new
(
group
,
user2
).
execute
(
params:
{
two_factor:
'disabled'
})
result
=
described_class
.
new
(
group
,
user2
,
params:
{
two_factor:
'disabled'
}).
execute
expect
(
result
.
to_a
).
not_to
include
(
member_with_2fa
)
expect
(
result
.
to_a
).
not_to
include
(
member_with_2fa
)
expect
(
result
.
to_a
).
to
match_array
([
member1
,
member2
])
expect
(
result
.
to_a
).
to
match_array
([
member1
,
member2
])
...
...
spec/frontend/diffs/components/commit_item_spec.js
View file @
684d6531
...
@@ -30,12 +30,12 @@ describe('diffs/components/commit_item', () => {
...
@@ -30,12 +30,12 @@ describe('diffs/components/commit_item', () => {
const
getCommitActionsElement
=
()
=>
wrapper
.
find
(
'
.commit-actions
'
);
const
getCommitActionsElement
=
()
=>
wrapper
.
find
(
'
.commit-actions
'
);
const
getCommitPipelineStatus
=
()
=>
wrapper
.
find
(
CommitPipelineStatus
);
const
getCommitPipelineStatus
=
()
=>
wrapper
.
find
(
CommitPipelineStatus
);
const
defaultProps
=
{
const
mountComponent
=
propsData
=>
{
commit
:
getDiffWithCommit
().
commit
,
};
const
mountComponent
=
(
propsData
=
defaultProps
)
=>
{
wrapper
=
mount
(
Component
,
{
wrapper
=
mount
(
Component
,
{
propsData
,
propsData
:
{
commit
,
...
propsData
,
},
stubs
:
{
stubs
:
{
CommitPipelineStatus
:
true
,
CommitPipelineStatus
:
true
,
},
},
...
@@ -59,9 +59,7 @@ describe('diffs/components/commit_item', () => {
...
@@ -59,9 +59,7 @@ describe('diffs/components/commit_item', () => {
expect
(
titleElement
.
text
()).
toBe
(
commit
.
title_html
);
expect
(
titleElement
.
text
()).
toBe
(
commit
.
title_html
);
});
});
// https://gitlab.com/gitlab-org/gitlab/-/issues/209776
it
(
'
renders commit description
'
,
()
=>
{
// eslint-disable-next-line jest/no-disabled-tests
it
.
skip
(
'
renders commit description
'
,
()
=>
{
const
descElement
=
getDescElement
();
const
descElement
=
getDescElement
();
const
descExpandElement
=
getDescExpandElement
();
const
descExpandElement
=
getDescExpandElement
();
...
@@ -107,7 +105,7 @@ describe('diffs/components/commit_item', () => {
...
@@ -107,7 +105,7 @@ describe('diffs/components/commit_item', () => {
describe
(
'
without commit description
'
,
()
=>
{
describe
(
'
without commit description
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mountComponent
({
defaultProps
,
commit
:
{
...
defaultProps
.
commit
,
description_html
:
''
}
});
mountComponent
({
commit
:
{
..
.
commit
,
description_html
:
''
}
});
});
});
it
(
'
hides description
'
,
()
=>
{
it
(
'
hides description
'
,
()
=>
{
...
@@ -122,9 +120,8 @@ describe('diffs/components/commit_item', () => {
...
@@ -122,9 +120,8 @@ describe('diffs/components/commit_item', () => {
describe
(
'
with no matching user
'
,
()
=>
{
describe
(
'
with no matching user
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mountComponent
({
mountComponent
({
defaultProps
,
commit
:
{
commit
:
{
...
defaultProps
.
commit
,
...
commit
,
author
:
null
,
author
:
null
,
author_email
:
TEST_AUTHOR_EMAIL
,
author_email
:
TEST_AUTHOR_EMAIL
,
author_name
:
TEST_AUTHOR_NAME
,
author_name
:
TEST_AUTHOR_NAME
,
...
@@ -154,8 +151,7 @@ describe('diffs/components/commit_item', () => {
...
@@ -154,8 +151,7 @@ describe('diffs/components/commit_item', () => {
describe
(
'
with signature
'
,
()
=>
{
describe
(
'
with signature
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mountComponent
({
mountComponent
({
defaultProps
,
commit
:
{
...
commit
,
signature_html
:
TEST_SIGNATURE_HTML
},
commit
:
{
...
defaultProps
.
commit
,
signature_html
:
TEST_SIGNATURE_HTML
},
});
});
});
});
...
@@ -169,8 +165,7 @@ describe('diffs/components/commit_item', () => {
...
@@ -169,8 +165,7 @@ describe('diffs/components/commit_item', () => {
describe
(
'
with pipeline status
'
,
()
=>
{
describe
(
'
with pipeline status
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mountComponent
({
mountComponent
({
defaultProps
,
commit
:
{
...
commit
,
pipeline_status_path
:
TEST_PIPELINE_STATUS_PATH
},
commit
:
{
...
defaultProps
.
commit
,
pipeline_status_path
:
TEST_PIPELINE_STATUS_PATH
},
});
});
});
});
...
...
spec/lib/api/helpers/custom_validators_spec.rb
deleted
100644 → 0
View file @
ade18c9d
# frozen_string_literal: true
require
'spec_helper'
describe
API
::
Helpers
::
CustomValidators
do
let
(
:scope
)
do
Struct
.
new
(
:opts
)
do
def
full_name
(
attr_name
)
attr_name
end
end
end
describe
API
::
Helpers
::
CustomValidators
::
Absence
do
subject
do
described_class
.
new
([
'test'
],
{},
false
,
scope
.
new
)
end
context
'empty param'
do
it
'does not raise a validation error'
do
expect_no_validation_error
({})
end
end
context
'invalid parameters'
do
it
'raises a validation error'
do
expect_validation_error
(
'test'
=>
'some_value'
)
end
end
end
describe
API
::
Helpers
::
CustomValidators
::
GitSha
do
let
(
:sha
)
{
RepoHelpers
.
sample_commit
.
id
}
let
(
:short_sha
)
{
sha
[
0
,
Gitlab
::
Git
::
Commit
::
MIN_SHA_LENGTH
]
}
let
(
:too_short_sha
)
{
sha
[
0
,
Gitlab
::
Git
::
Commit
::
MIN_SHA_LENGTH
-
1
]
}
subject
do
described_class
.
new
([
'test'
],
{},
false
,
scope
.
new
)
end
context
'valid sha'
do
it
'does not raise a validation error'
do
expect_no_validation_error
(
'test'
=>
sha
)
expect_no_validation_error
(
'test'
=>
short_sha
)
end
end
context
'empty params'
do
it
'raises a validation error'
do
expect_validation_error
(
'test'
=>
nil
)
expect_validation_error
(
'test'
=>
''
)
end
end
context
'invalid sha'
do
it
'raises a validation error'
do
expect_validation_error
(
'test'
=>
"
#{
sha
}
2"
)
# Sha length > 40
expect_validation_error
(
'test'
=>
'somestring'
)
expect_validation_error
(
'test'
=>
too_short_sha
)
# sha length < MIN_SHA_LENGTH (7)
end
end
end
describe
API
::
Helpers
::
CustomValidators
::
GitRef
do
subject
do
described_class
.
new
([
'test'
],
{},
false
,
scope
.
new
)
end
context
'valid revision param'
do
it
'does not raise a validation error'
do
expect_no_validation_error
(
'test'
=>
'4e963fe'
)
expect_no_validation_error
(
'test'
=>
'foo/bar/baz'
)
expect_no_validation_error
(
'test'
=>
"heads/fu
\303\237
"
)
expect_no_validation_error
(
'test'
=>
'a'
*
1024
)
end
end
context
"revision param contains invalid chars"
do
it
'raises a validation error'
do
expect_validation_error
(
'test'
=>
'-4e963fe'
)
expect_validation_error
(
'test'
=>
'4e963fe..ed4ef'
)
expect_validation_error
(
'test'
=>
'4e96\3fe'
)
expect_validation_error
(
'test'
=>
'4e96@3fe'
)
expect_validation_error
(
'test'
=>
'4e9@{63fe'
)
expect_validation_error
(
'test'
=>
'4e963 fe'
)
expect_validation_error
(
'test'
=>
'4e96~3fe'
)
expect_validation_error
(
'test'
=>
'^4e963fe'
)
expect_validation_error
(
'test'
=>
'4:e963fe'
)
expect_validation_error
(
'test'
=>
'4e963fe.'
)
expect_validation_error
(
'test'
=>
'heads/foo..bar'
)
expect_validation_error
(
'test'
=>
'foo/bar/.'
)
expect_validation_error
(
'test'
=>
'heads/v@{ation'
)
expect_validation_error
(
'test'
=>
'refs/heads/foo.'
)
expect_validation_error
(
'test'
=>
'heads/foo\bar'
)
expect_validation_error
(
'test'
=>
'heads/f[/bar'
)
expect_validation_error
(
'test'
=>
"heads/foo
\t
"
)
expect_validation_error
(
'test'
=>
"heads/foo
\177
"
)
expect_validation_error
(
'test'
=>
"
#{
'a'
*
1025
}
"
)
expect_validation_error
(
'test'
=>
nil
)
expect_validation_error
(
'test'
=>
''
)
end
end
end
describe
API
::
Helpers
::
CustomValidators
::
FilePath
do
subject
do
described_class
.
new
([
'test'
],
{},
false
,
scope
.
new
)
end
context
'valid file path'
do
it
'does not raise a validation error'
do
expect_no_validation_error
(
'test'
=>
'./foo'
)
expect_no_validation_error
(
'test'
=>
'./bar.rb'
)
expect_no_validation_error
(
'test'
=>
'foo%2Fbar%2Fnew%2Ffile.rb'
)
expect_no_validation_error
(
'test'
=>
'foo%2Fbar%2Fnew'
)
expect_no_validation_error
(
'test'
=>
'foo%252Fbar%252Fnew%252Ffile.rb'
)
end
end
context
'invalid file path'
do
it
'raise a validation error'
do
expect_validation_error
(
'test'
=>
'../foo'
)
expect_validation_error
(
'test'
=>
'../'
)
expect_validation_error
(
'test'
=>
'foo/../../bar'
)
expect_validation_error
(
'test'
=>
'foo/../'
)
expect_validation_error
(
'test'
=>
'foo/..'
)
expect_validation_error
(
'test'
=>
'../'
)
expect_validation_error
(
'test'
=>
'..\\'
)
expect_validation_error
(
'test'
=>
'..\/'
)
expect_validation_error
(
'test'
=>
'%2e%2e%2f'
)
expect_validation_error
(
'test'
=>
'/etc/passwd'
)
end
end
end
describe
API
::
Helpers
::
CustomValidators
::
IntegerNoneAny
do
subject
do
described_class
.
new
([
'test'
],
{},
false
,
scope
.
new
)
end
context
'valid parameters'
do
it
'does not raise a validation error'
do
expect_no_validation_error
(
'test'
=>
2
)
expect_no_validation_error
(
'test'
=>
100
)
expect_no_validation_error
(
'test'
=>
'None'
)
expect_no_validation_error
(
'test'
=>
'Any'
)
expect_no_validation_error
(
'test'
=>
'none'
)
expect_no_validation_error
(
'test'
=>
'any'
)
end
end
context
'invalid parameters'
do
it
'raises a validation error'
do
expect_validation_error
({
'test'
=>
'some_other_string'
})
end
end
end
describe
API
::
Helpers
::
CustomValidators
::
ArrayNoneAny
do
subject
do
described_class
.
new
([
'test'
],
{},
false
,
scope
.
new
)
end
context
'valid parameters'
do
it
'does not raise a validation error'
do
expect_no_validation_error
(
'test'
=>
[])
expect_no_validation_error
(
'test'
=>
[
1
,
2
,
3
])
expect_no_validation_error
(
'test'
=>
'None'
)
expect_no_validation_error
(
'test'
=>
'Any'
)
expect_no_validation_error
(
'test'
=>
'none'
)
expect_no_validation_error
(
'test'
=>
'any'
)
end
end
context
'invalid parameters'
do
it
'raises a validation error'
do
expect_validation_error
(
'test'
=>
'some_other_string'
)
end
end
end
def
expect_no_validation_error
(
params
)
expect
{
validate_test_param!
(
params
)
}.
not_to
raise_error
end
def
expect_validation_error
(
params
)
expect
{
validate_test_param!
(
params
)
}.
to
raise_error
(
Grape
::
Exceptions
::
Validation
)
end
def
validate_test_param!
(
params
)
subject
.
validate_param!
(
'test'
,
params
)
end
end
spec/lib/api/validations/validators/absence_spec.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
require
'spec_helper'
describe
API
::
Validations
::
Validators
::
Absence
do
include
ApiValidatorsHelpers
subject
do
described_class
.
new
([
'test'
],
{},
false
,
scope
.
new
)
end
context
'empty param'
do
it
'does not raise a validation error'
do
expect_no_validation_error
({})
end
end
context
'invalid parameters'
do
it
'raises a validation error'
do
expect_validation_error
(
'test'
=>
'some_value'
)
end
end
end
spec/lib/api/validations/validators/array_none_any_spec.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
require
'spec_helper'
describe
API
::
Validations
::
Validators
::
ArrayNoneAny
do
include
ApiValidatorsHelpers
subject
do
described_class
.
new
([
'test'
],
{},
false
,
scope
.
new
)
end
context
'valid parameters'
do
it
'does not raise a validation error'
do
expect_no_validation_error
(
'test'
=>
[])
expect_no_validation_error
(
'test'
=>
[
1
,
2
,
3
])
expect_no_validation_error
(
'test'
=>
'None'
)
expect_no_validation_error
(
'test'
=>
'Any'
)
expect_no_validation_error
(
'test'
=>
'none'
)
expect_no_validation_error
(
'test'
=>
'any'
)
end
end
context
'invalid parameters'
do
it
'raises a validation error'
do
expect_validation_error
(
'test'
=>
'some_other_string'
)
end
end
end
spec/lib/api/validations/validators/file_path_spec.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
require
'spec_helper'
describe
API
::
Validations
::
Validators
::
FilePath
do
include
ApiValidatorsHelpers
subject
do
described_class
.
new
([
'test'
],
{},
false
,
scope
.
new
)
end
context
'valid file path'
do
it
'does not raise a validation error'
do
expect_no_validation_error
(
'test'
=>
'./foo'
)
expect_no_validation_error
(
'test'
=>
'./bar.rb'
)
expect_no_validation_error
(
'test'
=>
'foo%2Fbar%2Fnew%2Ffile.rb'
)
expect_no_validation_error
(
'test'
=>
'foo%2Fbar%2Fnew'
)
expect_no_validation_error
(
'test'
=>
'foo%252Fbar%252Fnew%252Ffile.rb'
)
end
end
context
'invalid file path'
do
it
'raise a validation error'
do
expect_validation_error
(
'test'
=>
'../foo'
)
expect_validation_error
(
'test'
=>
'../'
)
expect_validation_error
(
'test'
=>
'foo/../../bar'
)
expect_validation_error
(
'test'
=>
'foo/../'
)
expect_validation_error
(
'test'
=>
'foo/..'
)
expect_validation_error
(
'test'
=>
'../'
)
expect_validation_error
(
'test'
=>
'..\\'
)
expect_validation_error
(
'test'
=>
'..\/'
)
expect_validation_error
(
'test'
=>
'%2e%2e%2f'
)
expect_validation_error
(
'test'
=>
'/etc/passwd'
)
end
end
end
spec/lib/api/validations/validators/git_ref_spec.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
require
'spec_helper'
describe
API
::
Validations
::
Validators
::
GitRef
do
include
ApiValidatorsHelpers
subject
do
described_class
.
new
([
'test'
],
{},
false
,
scope
.
new
)
end
context
'valid revision param'
do
it
'does not raise a validation error'
do
expect_no_validation_error
(
'test'
=>
'4e963fe'
)
expect_no_validation_error
(
'test'
=>
'foo/bar/baz'
)
expect_no_validation_error
(
'test'
=>
"heads/fu
\303\237
"
)
expect_no_validation_error
(
'test'
=>
'a'
*
1024
)
end
end
context
"revision param contains invalid chars"
do
it
'raises a validation error'
do
expect_validation_error
(
'test'
=>
'-4e963fe'
)
expect_validation_error
(
'test'
=>
'4e963fe..ed4ef'
)
expect_validation_error
(
'test'
=>
'4e96\3fe'
)
expect_validation_error
(
'test'
=>
'4e96@3fe'
)
expect_validation_error
(
'test'
=>
'4e9@{63fe'
)
expect_validation_error
(
'test'
=>
'4e963 fe'
)
expect_validation_error
(
'test'
=>
'4e96~3fe'
)
expect_validation_error
(
'test'
=>
'^4e963fe'
)
expect_validation_error
(
'test'
=>
'4:e963fe'
)
expect_validation_error
(
'test'
=>
'4e963fe.'
)
expect_validation_error
(
'test'
=>
'heads/foo..bar'
)
expect_validation_error
(
'test'
=>
'foo/bar/.'
)
expect_validation_error
(
'test'
=>
'heads/v@{ation'
)
expect_validation_error
(
'test'
=>
'refs/heads/foo.'
)
expect_validation_error
(
'test'
=>
'heads/foo\bar'
)
expect_validation_error
(
'test'
=>
'heads/f[/bar'
)
expect_validation_error
(
'test'
=>
"heads/foo
\t
"
)
expect_validation_error
(
'test'
=>
"heads/foo
\177
"
)
expect_validation_error
(
'test'
=>
"
#{
'a'
*
1025
}
"
)
expect_validation_error
(
'test'
=>
nil
)
expect_validation_error
(
'test'
=>
''
)
end
end
end
spec/lib/api/validations/validators/git_sha_spec.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
require
'spec_helper'
describe
API
::
Validations
::
Validators
::
GitSha
do
include
ApiValidatorsHelpers
let
(
:sha
)
{
RepoHelpers
.
sample_commit
.
id
}
let
(
:short_sha
)
{
sha
[
0
,
Gitlab
::
Git
::
Commit
::
MIN_SHA_LENGTH
]
}
let
(
:too_short_sha
)
{
sha
[
0
,
Gitlab
::
Git
::
Commit
::
MIN_SHA_LENGTH
-
1
]
}
subject
do
described_class
.
new
([
'test'
],
{},
false
,
scope
.
new
)
end
context
'valid sha'
do
it
'does not raise a validation error'
do
expect_no_validation_error
(
'test'
=>
sha
)
expect_no_validation_error
(
'test'
=>
short_sha
)
end
end
context
'empty params'
do
it
'raises a validation error'
do
expect_validation_error
(
'test'
=>
nil
)
expect_validation_error
(
'test'
=>
''
)
end
end
context
'invalid sha'
do
it
'raises a validation error'
do
expect_validation_error
(
'test'
=>
"
#{
sha
}
2"
)
# Sha length > 40
expect_validation_error
(
'test'
=>
'somestring'
)
expect_validation_error
(
'test'
=>
too_short_sha
)
# sha length < MIN_SHA_LENGTH (7)
end
end
end
spec/lib/api/validations/validators/integer_none_any_spec.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
require
'spec_helper'
describe
API
::
Validations
::
Validators
::
IntegerNoneAny
do
include
ApiValidatorsHelpers
subject
do
described_class
.
new
([
'test'
],
{},
false
,
scope
.
new
)
end
context
'valid parameters'
do
it
'does not raise a validation error'
do
expect_no_validation_error
(
'test'
=>
2
)
expect_no_validation_error
(
'test'
=>
100
)
expect_no_validation_error
(
'test'
=>
'None'
)
expect_no_validation_error
(
'test'
=>
'Any'
)
expect_no_validation_error
(
'test'
=>
'none'
)
expect_no_validation_error
(
'test'
=>
'any'
)
end
end
context
'invalid parameters'
do
it
'raises a validation error'
do
expect_validation_error
({
'test'
=>
'some_other_string'
})
end
end
end
spec/lib/banzai/filter/autolink_filter_spec.rb
View file @
684d6531
...
@@ -192,11 +192,6 @@ describe Banzai::Filter::AutolinkFilter do
...
@@ -192,11 +192,6 @@ describe Banzai::Filter::AutolinkFilter do
expect
(
doc
.
text
).
to
eq
"See <<<
#{
link
}
>>>"
expect
(
doc
.
text
).
to
eq
"See <<<
#{
link
}
>>>"
end
end
it
'accepts link_attr options'
do
doc
=
filter
(
"See
#{
link
}
"
,
link_attr:
{
class:
'custom'
})
expect
(
doc
.
at_css
(
'a'
)[
'class'
]).
to
eq
'custom'
end
it
'escapes RTLO and other characters'
do
it
'escapes RTLO and other characters'
do
# rendered text looks like "http://example.com/evilexe.mp3"
# rendered text looks like "http://example.com/evilexe.mp3"
evil_link
=
"
#{
link
}
evil
\u
202E3pm.exe"
evil_link
=
"
#{
link
}
evil
\u
202E3pm.exe"
...
...
spec/lib/gitlab/git/blob_spec.rb
View file @
684d6531
...
@@ -409,37 +409,43 @@ describe Gitlab::Git::Blob, :seed_helper do
...
@@ -409,37 +409,43 @@ describe Gitlab::Git::Blob, :seed_helper do
end
end
end
end
describe
'encoding'
do
describe
'encoding'
,
:aggregate_failures
do
context
'file with russian text'
do
context
'file with russian text'
do
let
(
:blob
)
{
Gitlab
::
Git
::
Blob
.
find
(
repository
,
SeedRepo
::
Commit
::
ID
,
"encoding/russian.rb"
)
}
let
(
:blob
)
{
Gitlab
::
Git
::
Blob
.
find
(
repository
,
SeedRepo
::
Commit
::
ID
,
"encoding/russian.rb"
)
}
it
{
expect
(
blob
.
name
).
to
eq
(
"russian.rb"
)
}
it
'has the correct blob attributes'
do
it
{
expect
(
blob
.
data
.
lines
.
first
).
to
eq
(
"Хороший файл"
)
}
expect
(
blob
.
name
).
to
eq
(
"russian.rb"
)
it
{
expect
(
blob
.
size
).
to
eq
(
23
)
}
expect
(
blob
.
data
.
lines
.
first
).
to
eq
(
"Хороший файл"
)
it
{
expect
(
blob
.
truncated?
).
to
be_falsey
}
expect
(
blob
.
size
).
to
eq
(
23
)
# Run it twice since data is encoded after the first run
expect
(
blob
.
truncated?
).
to
be_falsey
it
{
expect
(
blob
.
truncated?
).
to
be_falsey
}
# Run it twice since data is encoded after the first run
it
{
expect
(
blob
.
mode
).
to
eq
(
"100755"
)
}
expect
(
blob
.
truncated?
).
to
be_falsey
expect
(
blob
.
mode
).
to
eq
(
"100755"
)
end
end
end
context
'file with Japanese text'
do
context
'file with Japanese text'
do
let
(
:blob
)
{
Gitlab
::
Git
::
Blob
.
find
(
repository
,
SeedRepo
::
Commit
::
ID
,
"encoding/テスト.txt"
)
}
let
(
:blob
)
{
Gitlab
::
Git
::
Blob
.
find
(
repository
,
SeedRepo
::
Commit
::
ID
,
"encoding/テスト.txt"
)
}
it
{
expect
(
blob
.
name
).
to
eq
(
"テスト.txt"
)
}
it
'has the correct blob attributes'
do
it
{
expect
(
blob
.
data
).
to
include
(
"これはテスト"
)
}
expect
(
blob
.
name
).
to
eq
(
"テスト.txt"
)
it
{
expect
(
blob
.
size
).
to
eq
(
340
)
}
expect
(
blob
.
data
).
to
include
(
"これはテスト"
)
it
{
expect
(
blob
.
mode
).
to
eq
(
"100755"
)
}
expect
(
blob
.
size
).
to
eq
(
340
)
it
{
expect
(
blob
.
truncated?
).
to
be_falsey
}
expect
(
blob
.
mode
).
to
eq
(
"100755"
)
expect
(
blob
.
truncated?
).
to
be_falsey
end
end
end
context
'file with ISO-8859 text'
do
context
'file with ISO-8859 text'
do
let
(
:blob
)
{
Gitlab
::
Git
::
Blob
.
find
(
repository
,
SeedRepo
::
LastCommit
::
ID
,
"encoding/iso8859.txt"
)
}
let
(
:blob
)
{
Gitlab
::
Git
::
Blob
.
find
(
repository
,
SeedRepo
::
LastCommit
::
ID
,
"encoding/iso8859.txt"
)
}
it
{
expect
(
blob
.
name
).
to
eq
(
"iso8859.txt"
)
}
it
'has the correct blob attributes'
do
it
{
expect
(
blob
.
loaded_size
).
to
eq
(
4
)
}
expect
(
blob
.
name
).
to
eq
(
"iso8859.txt"
)
it
{
expect
(
blob
.
size
).
to
eq
(
4
)
}
expect
(
blob
.
loaded_size
).
to
eq
(
4
)
it
{
expect
(
blob
.
mode
).
to
eq
(
"100644"
)
}
expect
(
blob
.
size
).
to
eq
(
4
)
it
{
expect
(
blob
.
truncated?
).
to
be_falsey
}
expect
(
blob
.
mode
).
to
eq
(
"100644"
)
expect
(
blob
.
truncated?
).
to
be_falsey
end
end
end
end
end
...
...
spec/models/ability_spec.rb
View file @
684d6531
...
@@ -137,12 +137,6 @@ describe Ability do
...
@@ -137,12 +137,6 @@ describe Ability do
expect
(
users_for_snippet
(
snippet
)).
to
match_array
([
author
])
expect
(
users_for_snippet
(
snippet
)).
to
match_array
([
author
])
end
end
it
'internal snippet is readable by all registered users'
do
snippet
=
create
(
:personal_snippet
,
:public
,
author:
author
)
expect
(
users_for_snippet
(
snippet
)).
to
match_array
(
users
)
end
it
'public snippet is readable by all users'
do
it
'public snippet is readable by all users'
do
snippet
=
create
(
:personal_snippet
,
:public
,
author:
author
)
snippet
=
create
(
:personal_snippet
,
:public
,
author:
author
)
...
...
spec/models/ci/build_spec.rb
View file @
684d6531
...
@@ -3337,7 +3337,7 @@ describe Ci::Build do
...
@@ -3337,7 +3337,7 @@ describe Ci::Build do
end
end
it
"doesn't save timeout"
do
it
"doesn't save timeout"
do
expect
{
run_job_without_exception
}.
not_to
change
{
job
.
reload
.
ensure_metadata
.
timeout
_source
}
expect
{
run_job_without_exception
}.
not_to
change
{
job
.
reload
.
ensure_metadata
.
timeout
}
end
end
it
"doesn't save timeout_source"
do
it
"doesn't save timeout_source"
do
...
...
spec/requests/api/deploy_tokens_spec.rb
View file @
684d6531
...
@@ -175,8 +175,12 @@ describe API::DeployTokens do
...
@@ -175,8 +175,12 @@ describe API::DeployTokens do
it
{
is_expected
.
to
have_gitlab_http_status
(
:no_content
)
}
it
{
is_expected
.
to
have_gitlab_http_status
(
:no_content
)
}
it
'deletes the deploy token'
do
it
'calls the deploy token destroy service'
do
expect
{
subject
}.
to
change
{
project
.
deploy_tokens
.
count
}.
by
(
-
1
)
expect
(
::
Projects
::
DeployTokens
::
DestroyService
).
to
receive
(
:new
)
.
with
(
project
,
user
,
token_id:
deploy_token
.
id
)
.
and_return
(
true
)
subject
end
end
context
'invalid request'
do
context
'invalid request'
do
...
@@ -187,9 +191,13 @@ describe API::DeployTokens do
...
@@ -187,9 +191,13 @@ describe API::DeployTokens do
end
end
it
'returns bad_request with invalid token id'
do
it
'returns bad_request with invalid token id'
do
delete
api
(
"/projects/
#{
project
.
id
}
/deploy_tokens/123abc"
,
user
)
expect
(
::
Projects
::
DeployTokens
::
DestroyService
).
to
receive
(
:new
)
.
with
(
project
,
user
,
token_id:
999
)
.
and_raise
(
ActiveRecord
::
RecordNotFound
)
delete
api
(
"/projects/
#{
project
.
id
}
/deploy_tokens/999"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
:
bad_request
)
expect
(
response
).
to
have_gitlab_http_status
(
:
not_found
)
end
end
end
end
end
end
...
@@ -307,10 +315,12 @@ describe API::DeployTokens do
...
@@ -307,10 +315,12 @@ describe API::DeployTokens do
group
.
add_maintainer
(
user
)
group
.
add_maintainer
(
user
)
end
end
it
'deletes the deploy token'
do
it
'calls the deploy token destroy service'
do
expect
{
subject
}.
to
change
{
group
.
deploy_tokens
.
count
}.
by
(
-
1
)
expect
(
::
Groups
::
DeployTokens
::
DestroyService
).
to
receive
(
:new
)
.
with
(
group
,
user
,
token_id:
group_deploy_token
.
id
)
.
and_return
(
true
)
expect
(
group
.
deploy_tokens
).
to
be_empty
subject
end
end
context
'invalid request'
do
context
'invalid request'
do
...
@@ -321,7 +331,11 @@ describe API::DeployTokens do
...
@@ -321,7 +331,11 @@ describe API::DeployTokens do
end
end
it
'returns not found with invalid deploy token id'
do
it
'returns not found with invalid deploy token id'
do
delete
api
(
"/groups/
#{
group
.
id
}
/deploy_tokens/bad_id"
,
user
)
expect
(
::
Groups
::
DeployTokens
::
DestroyService
).
to
receive
(
:new
)
.
with
(
group
,
user
,
token_id:
999
)
.
and_raise
(
ActiveRecord
::
RecordNotFound
)
delete
api
(
"/groups/
#{
group
.
id
}
/deploy_tokens/999"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
...
...
spec/serializers/diffs_entity_spec.rb
View file @
684d6531
...
@@ -26,5 +26,47 @@ describe DiffsEntity do
...
@@ -26,5 +26,47 @@ describe DiffsEntity do
:merge_request_diffs
,
:definition_path_prefix
:merge_request_diffs
,
:definition_path_prefix
)
)
end
end
context
"when a commit_id is passed"
do
let
(
:commits
)
{
merge_request
.
commits
}
let
(
:entity
)
do
described_class
.
new
(
merge_request_diffs
.
first
.
diffs
,
request:
request
,
merge_request:
merge_request
,
merge_request_diffs:
merge_request_diffs
,
commit:
commit
)
end
subject
{
entity
.
as_json
}
context
"when the passed commit is not the first or last in the group"
do
let
(
:commit
)
{
commits
.
third
}
it
'includes commit references for previous and next'
do
expect
(
subject
[
:commit
][
:prev_commit_id
]).
to
eq
(
commits
.
second
.
id
)
expect
(
subject
[
:commit
][
:next_commit_id
]).
to
eq
(
commits
.
fourth
.
id
)
end
end
context
"when the passed commit is the first in the group"
do
let
(
:commit
)
{
commits
.
first
}
it
'includes commit references for nil and next'
do
expect
(
subject
[
:commit
][
:prev_commit_id
]).
to
be_nil
expect
(
subject
[
:commit
][
:next_commit_id
]).
to
eq
(
commits
.
second
.
id
)
end
end
context
"when the passed commit is the last in the group"
do
let
(
:commit
)
{
commits
.
last
}
it
'includes commit references for previous and nil'
do
expect
(
subject
[
:commit
][
:prev_commit_id
]).
to
eq
(
commits
[
-
2
].
id
)
expect
(
subject
[
:commit
][
:next_commit_id
]).
to
be_nil
end
end
end
end
end
end
end
spec/services/groups/deploy_tokens/destroy_service_spec.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
require
'spec_helper'
describe
Groups
::
DeployTokens
::
DestroyService
do
it_behaves_like
'a deploy token deletion service'
do
let_it_be
(
:entity
)
{
create
(
:group
)
}
let_it_be
(
:deploy_token_class
)
{
GroupDeployToken
}
let_it_be
(
:deploy_token
)
{
create
(
:deploy_token
,
:group
,
groups:
[
entity
])
}
end
end
spec/services/projects/deploy_tokens/destroy_service_spec.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
require
'spec_helper'
describe
Projects
::
DeployTokens
::
DestroyService
do
it_behaves_like
'a deploy token deletion service'
do
let_it_be
(
:entity
)
{
create
(
:project
)
}
let_it_be
(
:deploy_token_class
)
{
ProjectDeployToken
}
let_it_be
(
:deploy_token
)
{
create
(
:deploy_token
,
projects:
[
entity
])
}
end
end
spec/services/resource_events/synthetic_milestone_notes_builder_service_spec.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
require
'spec_helper'
describe
ResourceEvents
::
SyntheticMilestoneNotesBuilderService
do
describe
'#execute'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:issue
)
{
create
(
:issue
,
author:
user
)
}
before
do
create_list
(
:resource_milestone_event
,
3
,
issue:
issue
)
stub_feature_flags
(
track_resource_milestone_change_events:
false
)
end
context
'when resource milestone events are disabled'
do
# https://gitlab.com/gitlab-org/gitlab/-/issues/212985
it
'still builds notes for existing resource milestone events'
do
notes
=
described_class
.
new
(
issue
,
user
).
execute
expect
(
notes
.
size
).
to
eq
(
3
)
end
end
end
end
spec/support/helpers/api_validators_helpers.rb
0 → 100644
View file @
684d6531
# frozen_string_literal: true
module
ApiValidatorsHelpers
def
scope
Struct
.
new
(
:opts
)
do
def
full_name
(
attr_name
)
attr_name
end
end
end
def
expect_no_validation_error
(
params
)
expect
{
validate_test_param!
(
params
)
}.
not_to
raise_error
end
def
expect_validation_error
(
params
)
expect
{
validate_test_param!
(
params
)
}.
to
raise_error
(
Grape
::
Exceptions
::
Validation
)
end
def
validate_test_param!
(
params
)
subject
.
validate_param!
(
'test'
,
params
)
end
end
spec/support/services/deploy_token_shared_examples.rb
View file @
684d6531
...
@@ -58,3 +58,25 @@ RSpec.shared_examples 'a deploy token creation service' do
...
@@ -58,3 +58,25 @@ RSpec.shared_examples 'a deploy token creation service' do
end
end
end
end
end
end
RSpec
.
shared_examples
'a deploy token deletion service'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:deploy_token_params
)
{
{
token_id:
deploy_token
.
id
}
}
describe
'#execute'
do
subject
{
described_class
.
new
(
entity
,
user
,
deploy_token_params
).
execute
}
it
"destroys a token record and it's associated DeployToken"
do
expect
{
subject
}.
to
change
{
deploy_token_class
.
count
}.
by
(
-
1
)
.
and
change
{
DeployToken
.
count
}.
by
(
-
1
)
end
context
'invalid token id'
do
let
(
:deploy_token_params
)
{
{
token_id:
9999
}
}
it
'raises an error'
do
expect
{
subject
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
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