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
3b941e0d
Commit
3b941e0d
authored
Nov 27, 2020
by
Steve Abrams
Committed by
Kerri Miller
Nov 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update package_file to use FileStoreMounter concern
parent
a9cdcc34
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
11 deletions
+4
-11
app/models/packages/package_file.rb
app/models/packages/package_file.rb
+2
-9
spec/models/packages/package_file_spec.rb
spec/models/packages/package_file_spec.rb
+2
-2
No files found.
app/models/packages/package_file.rb
View file @
3b941e0d
# frozen_string_literal: true
class
Packages::PackageFile
<
ApplicationRecord
include
UpdateProjectStatistics
include
FileStoreMounter
delegate
:project
,
:project_id
,
to: :package
delegate
:conan_file_type
,
to: :conan_file_metadatum
...
...
@@ -35,20 +36,12 @@ class Packages::PackageFile < ApplicationRecord
.
where
(
packages_conan_file_metadata:
{
conan_package_reference:
conan_package_reference
})
end
mount_uploader
:file
,
Packages
::
PackageFileUploader
after_save
:update_file_metadata
,
if: :saved_change_to_file?
mount_file_store_uploader
Packages
::
PackageFileUploader
update_project_statistics
project_statistics_name: :packages_size
before_save
:update_size_from_file
def
update_file_metadata
# The file.object_store is set during `uploader.store!`
# which happens after object is inserted/updated
self
.
update_column
(
:file_store
,
file
.
object_store
)
end
def
download_path
Gitlab
::
Routing
.
url_helpers
.
download_project_package_file_path
(
project
,
self
)
end
...
...
spec/models/packages/package_file_spec.rb
View file @
3b941e0d
...
...
@@ -61,14 +61,14 @@ RSpec.describe Packages::PackageFile, type: :model do
end
end
describe
'#update_file_
metadata
callback'
do
describe
'#update_file_
store
callback'
do
let_it_be
(
:package_file
)
{
build
(
:package_file
,
:nuget
,
size:
nil
)
}
subject
{
package_file
.
save!
}
it
'updates metadata columns'
do
expect
(
package_file
)
.
to
receive
(
:update_file_
metadata
)
.
to
receive
(
:update_file_
store
)
.
and_call_original
# This expectation uses a stub because we can no longer test a change from
...
...
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