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
e0d8d8ff
Commit
e0d8d8ff
authored
May 19, 2021
by
Furkan Ayhan
Committed by
Grzegorz Bizon
May 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the redundant update for API endpoint projects/:id/statuses/:sha
parent
df28ca91
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
18 deletions
+59
-18
changelogs/unreleased/326791-removing-redundant-update.yml
changelogs/unreleased/326791-removing-redundant-update.yml
+5
-0
lib/api/commit_statuses.rb
lib/api/commit_statuses.rb
+2
-4
spec/requests/api/commit_statuses_spec.rb
spec/requests/api/commit_statuses_spec.rb
+52
-14
No files found.
changelogs/unreleased/326791-removing-redundant-update.yml
0 → 100644
View file @
e0d8d8ff
---
title
:
Remove the redundant update for API endpoint projects/:id/statuses/:sha
merge_request
:
61470
author
:
type
:
performance
lib/api/commit_statuses.rb
View file @
e0d8d8ff
...
...
@@ -96,10 +96,8 @@ module API
protected:
user_project
.
protected_for?
(
ref
)
)
optional_attributes
=
attributes_for_keys
(
%w[target_url description coverage]
)
status
.
update
(
optional_attributes
)
if
optional_attributes
.
any?
updatable_optional_attributes
=
%w[target_url description coverage]
status
.
assign_attributes
(
attributes_for_keys
(
updatable_optional_attributes
))
if
status
.
valid?
status
.
update_older_statuses_retried!
if
Feature
.
enabled?
(
:ci_fix_commit_status_retried
,
user_project
,
default_enabled: :yaml
)
...
...
spec/requests/api/commit_statuses_spec.rb
View file @
e0d8d8ff
...
...
@@ -3,12 +3,12 @@
require
'spec_helper'
RSpec
.
describe
API
::
CommitStatuses
do
let
!
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:commit
)
{
project
.
repository
.
commit
}
let
(
:guest
)
{
create_user
(
:guest
)
}
let
(
:reporter
)
{
create_user
(
:reporter
)
}
let
(
:developer
)
{
create_user
(
:developer
)
}
let
(
:sha
)
{
commit
.
id
}
let
_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let
_it_be
(
:commit
)
{
project
.
repository
.
commit
}
let
_it_be
(
:guest
)
{
create_user
(
:guest
)
}
let
_it_be
(
:reporter
)
{
create_user
(
:reporter
)
}
let
_it_be
(
:developer
)
{
create_user
(
:developer
)
}
let
_it_be
(
:sha
)
{
commit
.
id
}
describe
"GET /projects/:id/repository/commits/:sha/statuses"
do
let
(
:get_url
)
{
"/projects/
#{
project
.
id
}
/repository/commits/
#{
sha
}
/statuses"
}
...
...
@@ -233,27 +233,44 @@ RSpec.describe API::CommitStatuses do
end
end
context
'when updatig a commit status'
do
context
'when updating a commit status'
do
let
(
:parameters
)
do
{
state:
'success'
,
name:
'coverage'
,
ref:
'master'
}
end
let
(
:updatable_optional_attributes
)
do
{
description:
'new description'
,
coverage:
90.0
}
end
# creating the initial commit status
before
do
post
api
(
post_url
,
developer
),
params:
{
state:
'running'
,
context:
'coverage'
,
ref:
'master'
,
description:
'coverage test'
,
coverage:
0.0
,
coverage:
1
0.0
,
target_url:
'http://gitlab.com/status'
}
end
subject
(
:send_request
)
do
post
api
(
post_url
,
developer
),
params:
{
state:
'success'
,
name:
'coverage'
,
ref:
'master'
,
description:
'new description'
,
coverage:
90.0
**
parameters
,
**
updatable_optional_attributes
}
end
it
'updates a commit status'
do
send_request
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
...
...
@@ -265,7 +282,28 @@ RSpec.describe API::CommitStatuses do
end
it
'does not create a new commit status'
do
expect
(
CommitStatus
.
count
).
to
eq
1
expect
{
send_request
}.
not_to
change
{
CommitStatus
.
count
}
end
context
'when the `state` parameter is sent the same'
do
let
(
:parameters
)
do
{
state:
'running'
,
name:
'coverage'
,
ref:
'master'
}
end
it
'does not update the commit status'
do
send_request
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
commit_status
=
project
.
commit_statuses
.
find_by!
(
name:
'coverage'
)
expect
(
commit_status
.
description
).
to
eq
(
'coverage test'
)
expect
(
commit_status
.
coverage
).
to
eq
(
10.0
)
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