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
922a9c91
Commit
922a9c91
authored
Jun 05, 2020
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY commit REST API creation specs
parent
40b85ac2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
12 deletions
+19
-12
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+19
-12
No files found.
spec/requests/api/commits_spec.rb
View file @
922a9c91
...
...
@@ -356,28 +356,35 @@ describe API::Commits do
}
end
shared_examples_for
"successfully creates the commit"
do
it
"creates the commit"
do
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'committer_name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'committer_email'
]).
to
eq
(
user
.
email
)
end
end
it
'does not increment the usage counters using access token authentication'
do
expect
(
::
Gitlab
::
UsageDataCounters
::
WebIdeCounter
).
not_to
receive
(
:increment_commits_count
)
post
api
(
url
,
user
),
params:
valid_c_params
end
it
'a new file in project repo'
do
context
'a new file in project repo'
do
before
do
post
api
(
url
,
user
),
params:
valid_c_params
end
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'committer_name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'committer_email'
]).
to
eq
(
user
.
email
)
it_behaves_like
"successfully creates the commit"
end
it
'a new file with utf8 chars in project repo'
do
context
'a new file with utf8 chars in project repo'
do
before
do
post
api
(
url
,
user
),
params:
valid_utf8_c_params
end
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
expect
(
json_response
[
'committer_name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'committer_email'
]).
to
eq
(
user
.
email
)
it_behaves_like
"successfully creates the commit"
end
it
'returns a 400 bad request if file exists'
do
...
...
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