autoregister cqrs handlers fails to handle sub dirs
Bug Report
Summary
e.g. in users there are braintree commands within the commands dir. After auto registering the commands dir:
NexusCqrs::CommandBus::UnregisteredHandler:
Missing handler for Commands::Braintree::RequestSubscriptionCancellation
Steps to reproduce
Run tests in web-dev/users#458
What is the expected behaviour?
All command handlers should be registered below the supplied dir, recursively.
Other information
Attempting to register the subdir encounters another error involving dupe classes.
NexusCqrs::CommandBus::MultipleHandlers:
Multiple handlers not allowed for Commands::CreateRole
# /usr/local/bundle/gems/nexus_cqrs-0.4.0/lib/nexus_cqrs/command_bus.rb:28:in `register'
Expected since autoregister proceeds to check the entire ObjectSpace, does not appear to be designed to be run twice with the same base_class.
Expect we can resolve by changing the ruby directory pre processing to iterate recursively.
Perhaps (not tried):
Dir["#{dir}/**/*.rb"].each do |file|
Checklist
-
Include brief description of the bug -
Set out reproduction steps - make sure whoever is fixing this knows how to recreate the bug! -
Set a priority label following the definitions in the priority matrix -
If you know what Milestone and Iteration the bug is part of, add those too! -
If the bug is related to an existing feature issue/story, make sure to add it as a linked issue -
If this bug has a priority of P1 or P2, post a link to it in the Slack Channel bug-priority-reports
Edited by John Harris