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
8a14548f
Commit
8a14548f
authored
Jan 02, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for duplicate link name creation
Fix spec for mysql unique validation failure
parent
f5f52da8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
23 deletions
+34
-23
app/services/releases/create_service.rb
app/services/releases/create_service.rb
+1
-1
spec/requests/api/releases_spec.rb
spec/requests/api/releases_spec.rb
+33
-22
No files found.
app/services/releases/create_service.rb
View file @
8a14548f
...
@@ -48,7 +48,7 @@ module Releases
...
@@ -48,7 +48,7 @@ module Releases
)
)
success
(
tag:
tag
,
release:
release
)
success
(
tag:
tag
,
release:
release
)
rescue
ActiveRecord
::
RecordInvalid
=>
e
rescue
=>
e
error
(
e
.
message
,
400
)
error
(
e
.
message
,
400
)
end
end
end
end
...
...
spec/requests/api/releases_spec.rb
View file @
8a14548f
...
@@ -153,6 +153,7 @@ describe API::Releases do
...
@@ -153,6 +153,7 @@ describe API::Releases do
get
api
(
"/projects/
#{
project
.
id
}
/releases/v0.1"
,
maintainer
)
get
api
(
"/projects/
#{
project
.
id
}
/releases/v0.1"
,
maintainer
)
expect
(
json_response
[
'assets'
][
'links'
].
count
).
to
eq
(
1
)
expect
(
json_response
[
'assets'
][
'links'
].
count
).
to
eq
(
1
)
expect
(
json_response
[
'assets'
][
'links'
].
first
[
'id'
]).
to
eq
(
link
.
id
)
expect
(
json_response
[
'assets'
][
'links'
].
first
[
'name'
])
expect
(
json_response
[
'assets'
][
'links'
].
first
[
'name'
])
.
to
eq
(
'release-18.04.dmg'
)
.
to
eq
(
'release-18.04.dmg'
)
expect
(
json_response
[
'assets'
][
'links'
].
first
[
'url'
])
expect
(
json_response
[
'assets'
][
'links'
].
first
[
'url'
])
...
@@ -303,19 +304,21 @@ describe API::Releases do
...
@@ -303,19 +304,21 @@ describe API::Releases do
end
end
context
'when create assets altogether'
do
context
'when create assets altogether'
do
let
(
:base_params
)
do
{
name:
'New release'
,
tag_name:
'v0.1'
,
description:
'Super nice release'
}
end
context
'when create one asset'
do
context
'when create one asset'
do
let
(
:params
)
do
let
(
:params
)
do
{
base_params
.
merge
({
name:
'New release'
,
tag_name:
'v0.1'
,
description:
'Super nice release'
,
links_attributes:
[
links_attributes:
[
{
{
name:
'beta'
,
url:
'https://dosuken.example.com/inspection.exe'
}
name:
'beta'
,
url:
'https://dosuken.example.com/inspection.exe'
}
]
]
}
}
)
end
end
it
'accepts the request'
do
it
'accepts the request'
do
...
@@ -342,21 +345,12 @@ describe API::Releases do
...
@@ -342,21 +345,12 @@ describe API::Releases do
context
'when create two assets'
do
context
'when create two assets'
do
let
(
:params
)
do
let
(
:params
)
do
{
base_params
.
merge
({
name:
'New release'
,
tag_name:
'v0.1'
,
description:
'Super nice release'
,
links_attributes:
[
links_attributes:
[
{
{
name:
'alpha'
,
url:
'https://dosuken.example.com/alpha.exe'
},
name:
'alpha'
,
{
name:
'beta'
,
url:
'https://dosuken.example.com/beta.exe'
}
url:
'https://dosuken.example.com/alpha.exe'
},
{
name:
'beta'
,
url:
'https://dosuken.example.com/beta.exe'
}
]
]
}
}
)
end
end
it
'creates two assets with specified parameters'
do
it
'creates two assets with specified parameters'
do
...
@@ -369,6 +363,23 @@ describe API::Releases do
...
@@ -369,6 +363,23 @@ describe API::Releases do
.
to
match_array
(
%w[https://dosuken.example.com/alpha.exe
.
to
match_array
(
%w[https://dosuken.example.com/alpha.exe
https://dosuken.example.com/beta.exe]
)
https://dosuken.example.com/beta.exe]
)
end
end
context
'when link names are duplicates'
do
let
(
:params
)
do
base_params
.
merge
({
links_attributes:
[
{
name:
'alpha'
,
url:
'https://dosuken.example.com/alpha.exe'
},
{
name:
'alpha'
,
url:
'https://dosuken.example.com/beta.exe'
}
]
})
end
it
'recognizes as a bad request'
do
post
api
(
"/projects/
#{
project
.
id
}
/releases"
,
maintainer
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
end
end
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