Add a method to return the consumer class name

parent 2b566300
......@@ -19,5 +19,9 @@ module Geo
::Gitlab::Database::Subquery.self_join(limit(limit)).delete_all
end
end
def consumer_klass_name
self.class.name.demodulize
end
end
end
......@@ -114,7 +114,7 @@ module Gitlab
end
def event_klass_for(event)
event_klass_name = event.class.name.demodulize
event_klass_name = event.consumer_klass_name
current_namespace = self.class.name.deconstantize
Object.const_get("#{current_namespace}::Events::#{event_klass_name}", false)
end
......
......@@ -20,4 +20,12 @@ RSpec.describe Geo::Eventable do
end.to change { Geo::RepositoryUpdatedEvent.count }.by(-2)
end
end
describe '#consumer_klass_name' do
it 'returns the even class name without the module part' do
event = build(:geo_repository_created_event)
expect(event.consumer_klass_name).to eq 'RepositoryCreatedEvent'
end
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