Merged
Conversation
a33b9e9 to
b07606e
Compare
ahukkanen
requested changes
Jul 12, 2023
Contributor
ahukkanen
left a comment
There was a problem hiding this comment.
I have gone through the code as well as tested this by adding the following initializer code in the development application:
log_path = Rails.root.join("log/testing_events.log")
logger = Logger.new(log_path)
logger.info("Started the application!")
Decidim::EventsManager.subscribe("decidim.admin.block_user:before") do |event_name, data|
logger.info("Block user -- BEFORE")
logger.info(event_name.inspect)
logger.info(data.inspect)
end
Decidim::EventsManager.subscribe("decidim.admin.block_user:after") do |event_name, data|
logger.info("Block user -- AFTER")
logger.info(event_name.inspect)
logger.info(data.inspect)
endIt worked great and logged both events when I blocked a user.
Overall I really like the approach, I have just left a couple of comments regarding some code clarification and regarding the with_events method itself which I think could be simplified.
Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>
ahukkanen
reviewed
Jul 13, 2023
Contributor
ahukkanen
left a comment
There was a problem hiding this comment.
Just one more remark and this is good to go for me.
There may be a reason for this but I didn't understand it.
decidim-core/lib/decidim/core/test/shared_examples/active_support_examples.rb
Outdated
Show resolved
Hide resolved
ahukkanen
approved these changes
Jul 13, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎩 What? Why?
In the review of #10151, @ahukkanen suggested to use a hook method in the commands so that we can easily issue ActiveSupport Notifications that can be subscribed to from various places of Decidim application. While implementing this, i have seen that we already have some other events that we dispatch, so, in order to have a consolidated mode of issuing application wide events, i have created this PR.
📌 Related Issues
Link your PR to an issue
Testing
Follow the test scenarios in #6804 and #10111