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
678846d1
Commit
678846d1
authored
Feb 25, 2020
by
Mike Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test Blob Replicators
parent
dc0eedf2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
30 deletions
+66
-30
ee/spec/replicators/geo/package_file_replicator_spec.rb
ee/spec/replicators/geo/package_file_replicator_spec.rb
+2
-30
spec/support/shared_examples/models/concerns/blob_replicator_strategy_shared_examples.rb
...dels/concerns/blob_replicator_strategy_shared_examples.rb
+64
-0
No files found.
ee/spec/replicators/geo/package_file_replicator_spec.rb
View file @
678846d1
...
@@ -3,35 +3,7 @@
...
@@ -3,35 +3,7 @@
require
'spec_helper'
require
'spec_helper'
describe
Geo
::
PackageFileReplicator
do
describe
Geo
::
PackageFileReplicator
do
include
EE
::
GeoHelpers
let
(
:model_record
)
{
build
(
:package_file
,
:npm
)
}
let_it_be
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
it_behaves_like
'a blob replicator'
let_it_be
(
:secondary
)
{
create
(
:geo_node
)
}
let_it_be
(
:model_record
)
{
create
(
:package_file
,
:npm
)
}
subject
{
described_class
.
new
(
model_record:
model_record
)
}
before
do
stub_current_geo_node
(
primary
)
end
describe
'#publish_created_event'
do
it
"creates a Geo::Event"
do
expect
do
subject
.
publish_created_event
end
.
to
change
{
::
Geo
::
Event
.
count
}.
by
(
1
)
expect
(
::
Geo
::
Event
.
last
.
attributes
).
to
include
(
"replicable_name"
=>
"package_file"
,
"event_name"
=>
"created"
,
"payload"
=>
{
"model_record_id"
=>
model_record
.
id
})
end
end
describe
'#consume_created_event'
do
it
'invokes Geo::BlobDownloadService'
do
service
=
double
(
:service
)
expect
(
service
).
to
receive
(
:execute
)
expect
(
::
Geo
::
BlobDownloadService
).
to
receive
(
:new
).
with
(
replicator:
subject
).
and_return
(
service
)
subject
.
consume_created_event
end
end
end
end
spec/support/shared_examples/models/concerns/blob_replicator_strategy_shared_examples.rb
0 → 100644
View file @
678846d1
# frozen_string_literal: true
# Include these shared examples in specs of Replicators that include
# BlobReplicatorStrategy.
#
# A let variable called model_record should be defined in the spec. It should be
# a valid, unpersisted instance of the model class.
#
RSpec
.
shared_examples
'a blob replicator'
do
include
EE
::
GeoHelpers
let_it_be
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
let_it_be
(
:secondary
)
{
create
(
:geo_node
)
}
subject
(
:replicator
)
{
model_record
.
replicator
}
before
do
stub_current_geo_node
(
primary
)
end
describe
'#publish_created_event'
do
it
'creates a Geo::Event'
do
expect
do
replicator
.
publish_created_event
end
.
to
change
{
::
Geo
::
Event
.
count
}.
by
(
1
)
expect
(
::
Geo
::
Event
.
last
.
attributes
).
to
include
(
"replicable_name"
=>
replicator
.
replicable_name
,
"event_name"
=>
"created"
,
"payload"
=>
{
"model_record_id"
=>
replicator
.
model_record
.
id
})
end
end
describe
'#consume_created_event'
do
it
'invokes Geo::BlobDownloadService'
do
service
=
double
(
:service
)
expect
(
service
).
to
receive
(
:execute
)
expect
(
::
Geo
::
BlobDownloadService
).
to
receive
(
:new
).
with
(
replicator:
replicator
).
and_return
(
service
)
replicator
.
consume_created_event
end
end
describe
'#carrierwave_uploader'
do
it
'is implemented'
do
expect
do
replicator
.
carrierwave_uploader
end
.
not_to
raise_error
end
end
describe
'#model'
do
let
(
:invoke_model
)
{
replicator
.
send
(
:model
)
}
it
'is implemented'
do
expect
do
invoke_model
end
.
not_to
raise_error
end
it
'is a Class'
do
expect
(
invoke_model
).
to
be_a
(
Class
)
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