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
d7f7bdde
Commit
d7f7bdde
authored
Mar 25, 2021
by
Steve Abrams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add error status to package model
parent
c98d7517
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
3 deletions
+11
-3
app/models/packages/package.rb
app/models/packages/package.rb
+4
-2
spec/factories/packages.rb
spec/factories/packages.rb
+4
-0
spec/models/packages/package_spec.rb
spec/models/packages/package_spec.rb
+3
-1
No files found.
app/models/packages/package.rb
View file @
d7f7bdde
...
...
@@ -5,6 +5,8 @@ class Packages::Package < ApplicationRecord
include
UsageStatistics
include
Gitlab
::
Utils
::
StrongMemoize
DISPLAYABLE_STATUSES
=
[
:default
,
:error
].
freeze
belongs_to
:project
belongs_to
:creator
,
class_name:
'User'
...
...
@@ -70,7 +72,7 @@ class Packages::Package < ApplicationRecord
composer:
6
,
generic:
7
,
golang:
8
,
debian:
9
,
rubygems:
10
}
enum
status:
{
default:
0
,
hidden:
1
,
processing:
2
}
enum
status:
{
default:
0
,
hidden:
1
,
processing:
2
,
error:
3
}
scope
:with_name
,
->
(
name
)
{
where
(
name:
name
)
}
scope
:with_name_like
,
->
(
name
)
{
where
(
arel_table
[
:name
].
matches
(
name
))
}
...
...
@@ -80,7 +82,7 @@ class Packages::Package < ApplicationRecord
scope
:without_version_like
,
->
(
version
)
{
where
.
not
(
arel_table
[
:version
].
matches
(
version
))
}
scope
:with_package_type
,
->
(
package_type
)
{
where
(
package_type:
package_type
)
}
scope
:with_status
,
->
(
status
)
{
where
(
status:
status
)
}
scope
:displayable
,
->
{
with_status
(
:default
)
}
scope
:displayable
,
->
{
with_status
(
DISPLAYABLE_STATUSES
)
}
scope
:including_build_info
,
->
{
includes
(
pipelines: :user
)
}
scope
:including_project_route
,
->
{
includes
(
project:
{
namespace: :route
})
}
scope
:including_tags
,
->
{
includes
(
:tags
)
}
...
...
spec/factories/packages.rb
View file @
d7f7bdde
...
...
@@ -16,6 +16,10 @@ FactoryBot.define do
status
{
:processing
}
end
trait
:error
do
status
{
:error
}
end
factory
:maven_package
do
maven_metadatum
...
...
spec/models/packages/package_spec.rb
View file @
d7f7bdde
...
...
@@ -621,10 +621,12 @@ RSpec.describe Packages::Package, type: :model do
describe
'.displayable'
do
let_it_be
(
:hidden_package
)
{
create
(
:maven_package
,
:hidden
)
}
let_it_be
(
:processing_package
)
{
create
(
:maven_package
,
:processing
)
}
let_it_be
(
:error_package
)
{
create
(
:maven_package
,
:error
)
}
subject
{
described_class
.
displayable
}
it
'does not include hidden packages'
,
:aggregate_failures
do
it
'does not include non-displayable packages'
,
:aggregate_failures
do
is_expected
.
to
include
(
error_package
)
is_expected
.
not_to
include
(
hidden_package
)
is_expected
.
not_to
include
(
processing_package
)
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