Skip to content

Commit

Permalink
rails_test.rb: new instance var location
Browse files Browse the repository at this point in the history
The browser monitoring 'installed?' instance var has moved
  • Loading branch information
fallwith committed Oct 10, 2023
1 parent 2ef4bd2 commit c7b1f3d
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions test/new_relic/control/frameworks/rails_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
require_relative '../../../test_helper'

class NewRelic::Control::Frameworks::RailsTest < Minitest::Test
def setup
reset_installed_instance_variable
end

def teardown
reset_installed_instance_variable
end

def test_install_browser_monitoring
require 'new_relic/rack/browser_monitoring'
middleware = stub('middleware config')
config = stub('rails config', :middleware => middleware)
middleware.expects(:use).with(NewRelic::Rack::BrowserMonitoring)
NewRelic::Control.instance.instance_eval { @browser_monitoring_installed = false }
with_config(:'browser_monitoring.auto_instrument' => true) do
NewRelic::Control.instance.install_browser_monitoring(config)
end
Expand All @@ -20,10 +27,27 @@ def test_install_browser_monitoring_should_not_install_when_not_configured
middleware = stub('middleware config')
config = stub('rails config', :middleware => middleware)
middleware.expects(:use).never
NewRelic::Control.instance.instance_eval { @browser_monitoring_installed = false }

set_installed_instance_variable
with_config(:'browser_monitoring.auto_instrument' => false) do
NewRelic::Control.instance.install_browser_monitoring(config)
end
end

private

def reset_installed_instance_variable
return unless NewRelic::Control::Frameworks::Rails::INSTALLED_SINGLETON.instance_variable_defined?(
NewRelic::Control::Frameworks::Rails::INSTALLED
)

NewRelic::Control::Frameworks::Rails::INSTALLED_SINGLETON.remove_instance_variable(
NewRelic::Control::Frameworks::Rails::INSTALLED
)
end

def set_installed_instance_variable
NewRelic::Control::Frameworks::Rails::INSTALLED_SINGLETON.instance_variable_set(
NewRelic::Control::Frameworks::Rails::INSTALLED, true
)
end
end

0 comments on commit c7b1f3d

Please sign in to comment.