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
42455972
Commit
42455972
authored
Mar 09, 2020
by
David Fernandez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Favor `let_it_be` use instead of `let`
Avoid calling factories for nothing
parent
4e533563
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
34 deletions
+43
-34
ee/spec/requests/api/npm_packages_spec.rb
ee/spec/requests/api/npm_packages_spec.rb
+41
-32
ee/spec/support/shared_examples/requests/api/packages_tags_shared_examples.rb
...ed_examples/requests/api/packages_tags_shared_examples.rb
+2
-2
No files found.
ee/spec/requests/api/npm_packages_spec.rb
View file @
42455972
...
...
@@ -3,11 +3,12 @@
require
'spec_helper'
describe
API
::
NpmPackages
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
group
)
}
let
(
:token
)
{
create
(
:oauth_access_token
,
scopes:
'api'
,
resource_owner:
user
)
}
let
(
:job
)
{
create
(
:ci_build
,
user:
user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
,
:public
,
namespace:
group
)
}
let_it_be
(
:token
)
{
create
(
:oauth_access_token
,
scopes:
'api'
,
resource_owner:
user
)
}
let_it_be
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
)
}
let_it_be
(
:job
)
{
create
(
:ci_build
,
user:
user
)
}
before
do
project
.
add_developer
(
user
)
...
...
@@ -35,11 +36,11 @@ describe API::NpmPackages do
end
describe
'GET /api/v4/packages/npm/*package_name'
do
let
(
:package
)
{
create
(
:npm_package
,
project:
project
)
}
let
!
(
:package_dependency_link1
)
{
create
(
:packages_dependency_link
,
package:
package
,
dependency_type: :dependencies
)
}
let
!
(
:package_dependency_link2
)
{
create
(
:packages_dependency_link
,
package:
package
,
dependency_type: :devDependencies
)
}
let
!
(
:package_dependency_link3
)
{
create
(
:packages_dependency_link
,
package:
package
,
dependency_type: :bundleDependencies
)
}
let
!
(
:package_dependency_link4
)
{
create
(
:packages_dependency_link
,
package:
package
,
dependency_type: :peerDependencies
)
}
let
_it_be
(
:package
)
{
create
(
:npm_package
,
project:
project
)
}
let
_it_be
(
:package_dependency_link1
)
{
create
(
:packages_dependency_link
,
package:
package
,
dependency_type: :dependencies
)
}
let
_it_be
(
:package_dependency_link2
)
{
create
(
:packages_dependency_link
,
package:
package
,
dependency_type: :devDependencies
)
}
let
_it_be
(
:package_dependency_link3
)
{
create
(
:packages_dependency_link
,
package:
package
,
dependency_type: :bundleDependencies
)
}
let
_it_be
(
:package_dependency_link4
)
{
create
(
:packages_dependency_link
,
package:
package
,
dependency_type: :peerDependencies
)
}
shared_examples
'returning the npm package info'
do
it
'returns the package info'
do
...
...
@@ -106,7 +107,9 @@ describe API::NpmPackages do
end
context
'project path with a dot'
do
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
group
,
path:
'foo.bar'
)
}
before
do
project
.
update!
(
path:
'foo.bar'
)
end
it_behaves_like
'returning the npm package info'
end
...
...
@@ -159,8 +162,8 @@ describe API::NpmPackages do
end
describe
'GET /api/v4/projects/:id/packages/npm/*package_name/-/*file_name'
do
let
(
:package
)
{
create
(
:npm_package
,
project:
project
)
}
let
(
:package_file
)
{
package
.
package_files
.
first
}
let
_it_be
(
:package
)
{
create
(
:npm_package
,
project:
project
)
}
let
_it_be
(
:package_file
)
{
package
.
package_files
.
first
}
shared_examples
'a package file that requires auth'
do
it
'returns the file with an access token'
do
...
...
@@ -395,11 +398,11 @@ describe API::NpmPackages do
end
describe
'GET /api/v4/packages/npm/-/package/*package_name/dist-tags'
do
let
(
:package
)
{
create
(
:npm_package
,
project:
project
)
}
let!
(
:package_tag1
)
{
create
(
:packages_tag
,
package:
package
)
}
let!
(
:package_tag2
)
{
create
(
:packages_tag
,
package:
package
)
}
let_it_be
(
:package
)
{
create
(
:npm_package
,
project:
project
)
}
let_it_be
(
:package_tag1
)
{
create
(
:packages_tag
,
package:
package
)
}
let_it_be
(
:package_tag2
)
{
create
(
:packages_tag
,
package:
package
)
}
let
(
:package_name
)
{
package
.
name
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:url
)
{
"/packages/npm/-/package/
#{
package_name
}
/dist-tags"
}
subject
{
get
api
(
url
)
}
...
...
@@ -411,7 +414,7 @@ describe API::NpmPackages do
context
'with public project'
do
context
'with authenticated user'
do
subject
{
get
api
(
url
,
user
)
}
subject
{
get
api
(
url
,
personal_access_token:
personal_access_token
)
}
it_behaves_like
'returns package tags'
,
:maintainer
it_behaves_like
'returns package tags'
,
:developer
...
...
@@ -425,10 +428,12 @@ describe API::NpmPackages do
end
context
'with private project'
do
let
(
:project
)
{
create
(
:project
,
:private
)
}
before
do
project
.
update!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
context
'with authenticated user'
do
subject
{
get
api
(
url
,
user
)
}
subject
{
get
api
(
url
,
personal_access_token:
personal_access_token
)
}
it_behaves_like
'returns package tags'
,
:maintainer
it_behaves_like
'returns package tags'
,
:developer
...
...
@@ -452,10 +457,10 @@ describe API::NpmPackages do
end
describe
'PUT /api/v4/packages/npm/-/package/*package_name/dist-tags/:tag'
do
let
(
:package
)
{
create
(
:npm_package
,
project:
project
)
}
let_it_be
(
:package
,
reload:
true
)
{
create
(
:npm_package
,
project:
project
)
}
let_it_be
(
:tag_name
)
{
'test'
}
let
(
:package_name
)
{
package
.
name
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:tag_name
)
{
'test'
}
let
(
:version
)
{
package
.
version
}
let
(
:url
)
{
"/packages/npm/-/package/
#{
package_name
}
/dist-tags/
#{
tag_name
}
"
}
...
...
@@ -468,7 +473,7 @@ describe API::NpmPackages do
context
'with public project'
do
context
'with authenticated user'
do
subject
{
put
api
(
url
,
user
),
env:
{
'api.request.body'
:
version
}
}
subject
{
put
api
(
url
,
personal_access_token:
personal_access_token
),
env:
{
'api.request.body'
:
version
}
}
it_behaves_like
'create package tag'
,
:maintainer
it_behaves_like
'create package tag'
,
:developer
...
...
@@ -482,10 +487,12 @@ describe API::NpmPackages do
end
context
'with private project'
do
let
(
:project
)
{
create
(
:project
,
:private
)
}
before
do
project
.
update!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
context
'with authenticated user'
do
subject
{
put
api
(
url
,
user
),
env:
{
'api.request.body'
:
version
}
}
subject
{
put
api
(
url
,
personal_access_token:
personal_access_token
),
env:
{
'api.request.body'
:
version
}
}
it_behaves_like
'create package tag'
,
:maintainer
it_behaves_like
'create package tag'
,
:developer
...
...
@@ -509,9 +516,9 @@ describe API::NpmPackages do
end
describe
'DELETE /api/v4/packages/npm/-/package/*package_name/dist-tags/:tag'
do
let
(
:packag
e
)
{
create
(
:npm_package
,
project:
project
)
}
let
(
:package_tag
)
{
create
(
:packages_tag
,
package:
package
)
}
let
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:package
,
reload:
tru
e
)
{
create
(
:npm_package
,
project:
project
)
}
let
_it_be
(
:package_tag
)
{
create
(
:packages_tag
,
package:
package
)
}
let
(
:package_name
)
{
package
.
name
}
let
(
:tag_name
)
{
package_tag
.
name
}
let
(
:url
)
{
"/packages/npm/-/package/
#{
package_name
}
/dist-tags/
#{
tag_name
}
"
}
...
...
@@ -525,7 +532,7 @@ describe API::NpmPackages do
context
'with public project'
do
context
'with authenticated user'
do
subject
{
delete
api
(
url
,
user
)
}
subject
{
delete
api
(
url
,
personal_access_token:
personal_access_token
)
}
it_behaves_like
'delete package tag'
,
:maintainer
it_behaves_like
'rejects package tags access'
,
:developer
,
:forbidden
...
...
@@ -539,10 +546,12 @@ describe API::NpmPackages do
end
context
'with private project'
do
let
(
:project
)
{
create
(
:project
,
:private
)
}
before
do
project
.
update!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
context
'with authenticated user'
do
subject
{
delete
api
(
url
,
user
)
}
subject
{
delete
api
(
url
,
personal_access_token:
personal_access_token
)
}
it_behaves_like
'delete package tag'
,
:maintainer
it_behaves_like
'rejects package tags access'
,
:developer
,
:forbidden
...
...
ee/spec/support/shared_examples/requests/api/packages_tags_shared_examples.rb
View file @
42455972
...
...
@@ -73,8 +73,8 @@ RSpec.shared_examples 'create package tag' do |user_type|
end
context
'with already existing tag'
do
let
(
:package2
)
{
create
(
:npm_package
,
project:
project
,
name:
package
.
name
,
version:
'5.5.55'
)
}
let
!
(
:tag
)
{
create
(
:packages_tag
,
package:
package2
,
name:
tag_name
)
}
let
_it_be
(
:package2
)
{
create
(
:npm_package
,
project:
project
,
name:
package
.
name
,
version:
'5.5.55'
)
}
let
_it_be
(
:tag
)
{
create
(
:packages_tag
,
package:
package2
,
name:
tag_name
)
}
it_behaves_like
'returning response status'
,
:no_content
...
...
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