Skip to content

Commit

Permalink
Add instrumentation support
Browse files Browse the repository at this point in the history
  • Loading branch information
kushniryb committed Mar 21, 2023
1 parent a1974ad commit 8be0969
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/premailer/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ class Premailer
module Rails
class Railtie < ::Rails::Railtie
ActiveSupport.on_load(:action_mailer) do
::Premailer::Rails.register_interceptors
ActiveSupport::Notifications.instrument('register_interceptors.premailer_rails') do
::Premailer::Rails.register_interceptors
end
end
end
end
Expand Down
15 changes: 15 additions & 0 deletions spec/railtie_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'spec_helper'

describe Premailer::Rails::Railtie do
it 'supports instrumentation' do
subscriber = double().as_null_object

ActiveSupport::Notifications.subscribe('register_interceptors.premailer_rails') do
subscriber.call
end

ActiveSupport.run_load_hooks(:action_mailer, ActionMailer::Base)

expect(subscriber).to have_received(:call).at_least(:once)
end
end

0 comments on commit 8be0969

Please sign in to comment.