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
1be91c2e
Commit
1be91c2e
authored
Apr 05, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Does not count synced files that were replaced on attachments status
parent
233f4fb9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
app/models/geo_node_status.rb
app/models/geo_node_status.rb
+6
-1
spec/models/geo_node_status_spec.rb
spec/models/geo_node_status_spec.rb
+14
-0
No files found.
app/models/geo_node_status.rb
View file @
1be91c2e
...
...
@@ -69,7 +69,12 @@ class GeoNodeStatus
end
def
attachments_synced_count
@attachments_synced_count
||=
Geo
::
FileRegistry
.
where
(
file_type:
[
:attachment
,
:avatar
,
:file
]).
count
@attachments_synced_count
||=
begin
upload_ids
=
Upload
.
pluck
(
:id
)
synced_ids
=
Geo
::
FileRegistry
.
where
(
file_type:
[
:attachment
,
:avatar
,
:file
]).
pluck
(
:file_id
)
(
synced_ids
&
upload_ids
).
length
end
end
def
attachments_synced_count
=
(
value
)
...
...
spec/models/geo_node_status_spec.rb
View file @
1be91c2e
...
...
@@ -31,6 +31,20 @@ describe GeoNodeStatus, model: true do
end
end
describe
'#attachments_synced_count'
do
it
'does not count synced files that were replaced'
do
user
=
create
(
:user
,
avatar:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/png'
))
upload
=
Upload
.
find_by
(
model:
user
,
uploader:
'AvatarUploader'
)
Geo
::
FileRegistry
.
create
(
file_type: :avatar
,
file_id:
upload
.
id
)
user
.
update
(
avatar:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/rails_sample.jpg'
,
'image/jpg'
))
upload
=
Upload
.
find_by
(
model:
user
,
uploader:
'AvatarUploader'
)
Geo
::
FileRegistry
.
create
(
file_type: :avatar
,
file_id:
upload
.
id
)
expect
(
subject
.
attachments_synced_count
).
to
eq
(
1
)
end
end
describe
'#attachments_synced_in_percentage'
do
it
'returns 0 when no objects are available'
do
subject
.
attachments_count
=
0
...
...
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