Return the proper consumer class for design repositories

parent eaf4cfd1
......@@ -24,5 +24,16 @@ module Geo
def self.source_for(repository)
REPOSITORY_TYPE_MAP[repository.repo_type]
end
def consumer_klass_name
klass =
if design?
::Gitlab::Geo::LogCursor::Events::DesignRepositoryUpdatedEvent
else
self.class
end
klass.name.demodulize
end
end
end
......@@ -11,7 +11,25 @@ RSpec.describe Geo::RepositoryUpdatedEvent, type: :model do
it { is_expected.to validate_presence_of(:project) }
end
describe '#consumer_klass_name' do
using RSpec::Parameterized::TableSyntax
where(:source, :consumer_klass_name) do
:design | 'DesignRepositoryUpdatedEvent'
:repository | 'RepositoryUpdatedEvent'
:wiki | 'RepositoryUpdatedEvent'
end
with_them do
it 'returns the proper consumer class name' do
subject.source = source
expect(subject.consumer_klass_name).to eq consumer_klass_name
end
end
end
describe '#source' do
it { is_expected.to define_enum_for(:source).with([:repository, :wiki, :design]) }
it { is_expected.to define_enum_for(:source).with_values([:repository, :wiki, :design]) }
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