Feature/no request context#486
Conversation
|
Review status: 0 of 5 files reviewed at latest revision, 4 unresolved discussions. app/helpers/react_on_rails_helper.rb, line 348 [r1] (raw file):
how about if request.present?spec/dummy/app/mailers/dummy_mailer.rb, line 4 [r1] (raw file):
what is this comment? spec/dummy/app/views/dummy_mailer/hello_email.html.erb, line 7 [r1] (raw file):
needs line return -- see the red symbol spec/dummy/config/initializers/react_on_rails.rb, line 5 [r1] (raw file):
could we do this without a rescue? is there something in view_context that tells us we're in a mailer. This is the Rails API. Introspect on view_context in the debugger, like in pry. We also need to update the docs on the railsContext for this case, and in general for this fix. We should put in some flag that we're in mailer, like {
mailer: true | false;
}Comments from Reviewable |
|
Nice job @eacaps! Some comments! Reviewed 5 of 5 files at r1. Comments from Reviewable |
|
@justin808 I've made the first few tweaks you recommended. The last suggestion relates to a special custom_context that was already being added to the dummy tester. I tried several ways to get around using a rescue block but nothing really seems to work properly (.try, .respond_to, etc..). Accessing session from view_context uses a delegate from the ActionView::Helpers::ControllerHelper and since the base ActionMailer does not have a session method you end up with: undefined method `session' for #DummyMailer:0x007fe1c8e58f10. Since this is in the testing code and not the actual library I felt okay leaving the rescue block in there, but if anyone has another suggestion please feel free to make it. As far as improving the railsContext in this particular case those changes would be made in the react_on_rails_helper.rb in the rails_context method. The first thought that comes to mind would be changing the initial result to be
I haven't actually implemented that yet, but let me know if that all makes sense. |
|
Also I found this ancient rails issue related to ActionMailer delegation: rails/rails#15613. No action since 2014 but it describes the issue. |
|
Let's go with a property called Maybe to avoid the exception, we can have the customization of the railsContext check this inMailer flag? happy hacking! this is looking good! Reviewed 3 of 3 files at r2. spec/dummy/config/initializers/react_on_rails.rb, line 5 [r1] (raw file):
|
|
Looking good! Please squash your commits and address the following issues. be sure that Reviewed 3 of 3 files at r4. app/helpers/react_on_rails_helper.rb, line 347 [r4] (raw file):
Did this pass the linter? I'd probably rather see this on 3 lines. app/helpers/react_on_rails_helper.rb, line 365 [r4] (raw file):
can we move the spec/dummy/app/mailers/dummy_mailer.rb, line 4 [r1] (raw file):
|
|
@eacaps Any update? |
allow custom_context even without request added broken test added fixes to allow actionmailer test to pass cleaned up rubocop warnings resolved some reviewed suggestions updated with proper handles for inMailer added inMailer to test added inMailer checks for test cleaned up rubocop suggestions a few final minor tweaks
…on_rails into feature/no-request-context
|
@Xeboc Big thanks! My team is slammed with helping our paying clients. We are available for modestly priced coaching packs if anybody is interested: http://www.shakacode.com/work/. |
Recommended by Honeybadger docs: https://docs.honeybadger.io/lib/javascript/guides/environments-and-versions/
Recommended by Honeybadger docs: https://docs.honeybadger.io/lib/javascript/guides/environments-and-versions/
I recently moved our project from browserify to webpack using your tutorial. Great job on that! However I ran into an issue when attempting to use the react_component helper inside an actionmailer. The react_on_rails_helper.rb rails_context method expects to always come from a context that has a request. Unfortunately this is not the case when creating an e-mail via an ActionMailer. I did some basic modifications of react_on_rails_helper.rb to mitigate this issue and included a full test case in your test suite to handle this. You can see what was happening earlier by checking out this commit and running the tests. I'm obviously open to some tweaks to my implementation of rails_context since right now if there's no request it will just return an empty object.
Thanks again for your great work on react_on_rails, hopefully this will help.
This change is