Commit 253e2ba8 authored by Mike Kozono's avatar Mike Kozono

Extract ReplicableModel shared examples

into their own file.
parent aad9f49b
...@@ -20,6 +20,9 @@ RSpec.shared_examples 'a blob replicator' do ...@@ -20,6 +20,9 @@ RSpec.shared_examples 'a blob replicator' do
it_behaves_like 'a replicator' it_behaves_like 'a replicator'
# This could be included in each model's spec, but including it here is DRYer.
include_examples 'a replicable model'
describe '#handle_after_create_commit' do describe '#handle_after_create_commit' do
it 'creates a Geo::Event' do it 'creates a Geo::Event' do
expect do expect do
...@@ -172,18 +175,5 @@ RSpec.shared_examples 'a blob replicator' do ...@@ -172,18 +175,5 @@ RSpec.shared_examples 'a blob replicator' do
it 'is a Class' do it 'is a Class' do
expect(invoke_model).to be_a(Class) expect(invoke_model).to be_a(Class)
end end
# For convenience (and reliability), instead of asking developers to include shared examples on each model spec as well
context 'replicable model' do
it 'defines #replicator' do
expect(model_record).to respond_to(:replicator)
end
it 'invokes replicator.handle_after_create_commit on create' do
expect(replicator).to receive(:handle_after_create_commit)
model_record.save!
end
end
end end
end end
# frozen_string_literal: true
# Required let variables:
#
# - model_record: A valid, unpersisted instance of the model class
#
# We do not use `described_class` here, so we can include this in replicator
# strategy shared examples instead of in *every* model spec.
RSpec.shared_examples 'a replicable model' do
include EE::GeoHelpers
describe '#replicator' do
it 'is defined and does not raise error' do
expect(model_record.replicator).to be_a(Gitlab::Geo::Replicator)
end
end
it 'invokes replicator.handle_after_create_commit on create' do
expect(model_record.replicator).to receive(:handle_after_create_commit)
model_record.save!
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment