airbrake 3.2.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +8 -0
- data/Rakefile +11 -1
- data/features/step_definitions/rails_application_steps.rb +0 -26
- data/lib/airbrake/configuration.rb +1 -16
- data/lib/airbrake/rails.rb +0 -2
- data/lib/airbrake/railtie.rb +0 -6
- data/lib/airbrake/version.rb +1 -1
- data/test/configuration_test.rb +0 -8
- data/test/integration.rb +0 -1
- metadata +1 -8
- data/features/rails_with_js_notifier.feature +0 -104
- data/lib/airbrake/rails/javascript_notifier.rb +0 -85
- data/lib/templates/javascript_notifier_configuration +0 -12
- data/lib/templates/javascript_notifier_loader +0 -6
- data/test/integration/javascript_notifier_test.rb +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72e1f83cf5342499992360dfde17b8f6bf0561b0
|
4
|
+
data.tar.gz: f9ef7c0e8b84e83ce225242db2ac6f344664fe94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ce49cf00de6f908dc39b76061926de33500147cb3ac2e91766ed05f22a347c0dcad9704b0bf2535a745b01da96e39d4202dfee8ad46719b9f35e1c5901f64b4
|
7
|
+
data.tar.gz: a6cf1b8bf91759e3e5cfdd6cbc5d752720428f48465d87980522c3cab288b6115613b271a8521ba483a646836e98aa69bd86db03102d2dfdaac6dea8f8a13ea3
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
Version 4.0.0 - 2014-05-27 16:32:26 -0700
|
2
|
+
===============================================================================
|
3
|
+
|
4
|
+
Ali Faiz (2):
|
5
|
+
Remove the Airbrake JS notifier for the major release.
|
6
|
+
|
7
|
+
|
1
8
|
Version 3.2.1 - 2014-05-27 15:58:24 -0700
|
2
9
|
===============================================================================
|
3
10
|
|
@@ -1377,5 +1384,6 @@ Nick Quaranto (3):
|
|
1377
1384
|
|
1378
1385
|
|
1379
1386
|
|
1387
|
+
|
1380
1388
|
|
1381
1389
|
|
data/Rakefile
CHANGED
@@ -69,6 +69,10 @@ namespace :changeling do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
case args[:part]
|
72
|
+
when /major/
|
73
|
+
major += 1
|
74
|
+
minor = 0
|
75
|
+
patch = 0
|
72
76
|
when /minor/
|
73
77
|
minor += 1
|
74
78
|
patch = 0
|
@@ -114,6 +118,12 @@ EOF
|
|
114
118
|
"echo '\n\n\033[32mMarked v#{version} /' `git show-ref -s refs/heads/master` 'for release. Run: rake changeling:push\033[0m\n\n'"].join(' && ')
|
115
119
|
end
|
116
120
|
|
121
|
+
desc "Bump by a major version (1.2.3 => 2.0.0)"
|
122
|
+
task :major do |t|
|
123
|
+
Rake::Task['changeling:bump'].invoke(t.name)
|
124
|
+
Rake::Task['changeling:change'].invoke
|
125
|
+
end
|
126
|
+
|
117
127
|
desc "Bump by a minor version (1.2.3 => 1.3.0)"
|
118
128
|
task :minor do |t|
|
119
129
|
Rake::Task['changeling:bump'].invoke(t.name)
|
@@ -158,7 +168,7 @@ def cucumber_opts
|
|
158
168
|
|
159
169
|
case ENV["BUNDLE_GEMFILE"]
|
160
170
|
when /rails/
|
161
|
-
opts << "features/rails.feature features/
|
171
|
+
opts << "features/rails.feature features/metal.feature features/user_informer.feature"
|
162
172
|
when /rack/
|
163
173
|
opts << "features/rack.feature"
|
164
174
|
when /sinatra/
|
@@ -192,32 +192,6 @@ When /^I configure the application to filter parameter "([^\"]*)"$/ do |paramete
|
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
|
-
Then /^I should see the notifier JavaScript for the following:$/ do |table|
|
196
|
-
hash = table.hashes.first
|
197
|
-
host = hash['host'] || 'api.airbrake.io'
|
198
|
-
secure = hash['secure'] || false
|
199
|
-
api_key = hash['api_key']
|
200
|
-
environment = hash['environment'] || 'production'
|
201
|
-
|
202
|
-
steps %{
|
203
|
-
Then the output should contain "#{host}/javascripts/notifier.js"
|
204
|
-
And the output should contain "Airbrake.setKey('#{api_key}');"
|
205
|
-
And the output should contain "Airbrake.setHost('#{host}');"
|
206
|
-
And the output should contain "Airbrake.setEnvironment('#{environment}');"
|
207
|
-
}
|
208
|
-
end
|
209
|
-
|
210
|
-
Then /^the notifier JavaScript should provide the following errorDefaults:$/ do |table|
|
211
|
-
hash = table.hashes.first
|
212
|
-
hash.each do |key, value|
|
213
|
-
assert_matching_output("Airbrake\.setErrorDefaults.*#{key}: \"#{value}\"",all_output)
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
Then /^I should not see notifier JavaScript$/ do
|
218
|
-
step %{the output should not contain "script[type='text/javascript'][src$='/javascripts/notifier.js']"}
|
219
|
-
end
|
220
|
-
|
221
195
|
When /^I have set up authentication system in my app that uses "([^\"]*)"$/ do |current_user|
|
222
196
|
application_controller = File.join(rails_root, 'app', 'controllers', "application_controller.rb")
|
223
197
|
definition =
|
@@ -2,7 +2,7 @@ module Airbrake
|
|
2
2
|
# Used to set up and modify settings for the notifier.
|
3
3
|
class Configuration
|
4
4
|
|
5
|
-
OPTIONS = [:api_key, :
|
5
|
+
OPTIONS = [:api_key, :backtrace_filters, :development_environments,
|
6
6
|
:development_lookup, :environment_name, :host,
|
7
7
|
:http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters,
|
8
8
|
:ignore_user_agent, :notifier_name, :notifier_url, :notifier_version,
|
@@ -14,12 +14,6 @@ module Airbrake
|
|
14
14
|
# The API key for your project, found on the project edit form.
|
15
15
|
attr_accessor :api_key
|
16
16
|
|
17
|
-
# If you're using the Javascript notifier and would want to separate
|
18
|
-
# Javascript notifications into another Airbrake project, specify
|
19
|
-
# its APi key here.
|
20
|
-
# Defaults to #api_key (of the base project)
|
21
|
-
attr_writer :js_api_key
|
22
|
-
|
23
17
|
# The host to connect to (defaults to airbrake.io).
|
24
18
|
attr_accessor :host
|
25
19
|
|
@@ -158,7 +152,6 @@ module Airbrake
|
|
158
152
|
alias_method :use_system_ssl_cert_chain?, :use_system_ssl_cert_chain
|
159
153
|
|
160
154
|
def initialize
|
161
|
-
@js_api_key = nil
|
162
155
|
@secure = false
|
163
156
|
@use_system_ssl_cert_chain= false
|
164
157
|
@host = 'api.airbrake.io'
|
@@ -311,14 +304,6 @@ module Airbrake
|
|
311
304
|
@rescue_rake_exceptions = val
|
312
305
|
end
|
313
306
|
|
314
|
-
def js_api_key
|
315
|
-
@js_api_key || self.api_key
|
316
|
-
end
|
317
|
-
|
318
|
-
def js_notifier=(*args)
|
319
|
-
warn '[AIRBRAKE] config.js_notifier has been deprecated and has no effect. You should use <%= airbrake_javascript_notifier %> directly at the top of your layouts. Be sure to place it before all other javascript.'
|
320
|
-
end
|
321
|
-
|
322
307
|
def ca_bundle_path
|
323
308
|
if use_system_ssl_cert_chain? && File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE)
|
324
309
|
OpenSSL::X509::DEFAULT_CERT_FILE
|
data/lib/airbrake/rails.rb
CHANGED
@@ -2,7 +2,6 @@ require 'airbrake'
|
|
2
2
|
require 'airbrake/rails/controller_methods'
|
3
3
|
require 'airbrake/rails/action_controller_catcher'
|
4
4
|
require 'airbrake/rails/error_lookup'
|
5
|
-
require 'airbrake/rails/javascript_notifier'
|
6
5
|
|
7
6
|
module Airbrake
|
8
7
|
module Rails
|
@@ -11,7 +10,6 @@ module Airbrake
|
|
11
10
|
ActionController::Base.send(:include, Airbrake::Rails::ActionControllerCatcher)
|
12
11
|
ActionController::Base.send(:include, Airbrake::Rails::ErrorLookup)
|
13
12
|
ActionController::Base.send(:include, Airbrake::Rails::ControllerMethods)
|
14
|
-
ActionController::Base.send(:include, Airbrake::Rails::JavascriptNotifier)
|
15
13
|
end
|
16
14
|
|
17
15
|
rails_logger = if defined?(::Rails.logger)
|
data/lib/airbrake/railtie.rb
CHANGED
@@ -41,12 +41,6 @@ module Airbrake
|
|
41
41
|
|
42
42
|
include Airbrake::Rails::ControllerMethods
|
43
43
|
end
|
44
|
-
|
45
|
-
if defined?(::ActionController::Base)
|
46
|
-
require 'airbrake/rails/javascript_notifier'
|
47
|
-
|
48
|
-
::ActionController::Base.send(:include, Airbrake::Rails::JavascriptNotifier)
|
49
|
-
end
|
50
44
|
end
|
51
45
|
end
|
52
46
|
end
|
data/lib/airbrake/version.rb
CHANGED
data/test/configuration_test.rb
CHANGED
@@ -127,14 +127,6 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
127
127
|
assert_appends_value :rake_environment_filters
|
128
128
|
end
|
129
129
|
|
130
|
-
should "warn when attempting to write js_notifier" do
|
131
|
-
config = Airbrake::Configuration.new
|
132
|
-
config.
|
133
|
-
expects(:warn).
|
134
|
-
with(regexp_matches(/deprecated/i))
|
135
|
-
config.js_notifier = true
|
136
|
-
end
|
137
|
-
|
138
130
|
should "allow ignored user agents to be appended" do
|
139
131
|
assert_appends_value :ignore_user_agent
|
140
132
|
end
|
data/test/integration.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airbrake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Airbrake
|
@@ -311,7 +311,6 @@ files:
|
|
311
311
|
- features/metal.feature
|
312
312
|
- features/rack.feature
|
313
313
|
- features/rails.feature
|
314
|
-
- features/rails_with_js_notifier.feature
|
315
314
|
- features/rake.feature
|
316
315
|
- features/sinatra.feature
|
317
316
|
- features/step_definitions/file_steps.rb
|
@@ -351,7 +350,6 @@ files:
|
|
351
350
|
- lib/airbrake/rails/action_controller_catcher.rb
|
352
351
|
- lib/airbrake/rails/controller_methods.rb
|
353
352
|
- lib/airbrake/rails/error_lookup.rb
|
354
|
-
- lib/airbrake/rails/javascript_notifier.rb
|
355
353
|
- lib/airbrake/rails/middleware.rb
|
356
354
|
- lib/airbrake/rails3_tasks.rb
|
357
355
|
- lib/airbrake/railtie.rb
|
@@ -368,8 +366,6 @@ files:
|
|
368
366
|
- lib/airbrake/version.rb
|
369
367
|
- lib/airbrake_tasks.rb
|
370
368
|
- lib/rails/generators/airbrake/airbrake_generator.rb
|
371
|
-
- lib/templates/javascript_notifier_configuration
|
372
|
-
- lib/templates/javascript_notifier_loader
|
373
369
|
- lib/templates/rescue.erb
|
374
370
|
- rails/init.rb
|
375
371
|
- resources/README.md
|
@@ -385,7 +381,6 @@ files:
|
|
385
381
|
- test/helper.rb
|
386
382
|
- test/integration.rb
|
387
383
|
- test/integration/catcher_test.rb
|
388
|
-
- test/integration/javascript_notifier_test.rb
|
389
384
|
- test/logger_test.rb
|
390
385
|
- test/notice_test.rb
|
391
386
|
- test/notifier_test.rb
|
@@ -428,7 +423,6 @@ test_files:
|
|
428
423
|
- test/controller_methods_test.rb
|
429
424
|
- test/helper.rb
|
430
425
|
- test/integration/catcher_test.rb
|
431
|
-
- test/integration/javascript_notifier_test.rb
|
432
426
|
- test/integration.rb
|
433
427
|
- test/logger_test.rb
|
434
428
|
- test/notice_test.rb
|
@@ -444,7 +438,6 @@ test_files:
|
|
444
438
|
- features/metal.feature
|
445
439
|
- features/rack.feature
|
446
440
|
- features/rails.feature
|
447
|
-
- features/rails_with_js_notifier.feature
|
448
441
|
- features/rake.feature
|
449
442
|
- features/sinatra.feature
|
450
443
|
- features/step_definitions/file_steps.rb
|
@@ -1,104 +0,0 @@
|
|
1
|
-
Feature: Install the Gem in a Rails application and enable the JavaScript notifier
|
2
|
-
|
3
|
-
Background:
|
4
|
-
Given I successfully run `rails new rails_root -O --skip-gemfile`
|
5
|
-
And I cd to "rails_root"
|
6
|
-
And I configure the Airbrake shim
|
7
|
-
|
8
|
-
Scenario: Include the Javascript notifier when enabled
|
9
|
-
When I configure the notifier to use the following configuration lines:
|
10
|
-
"""
|
11
|
-
config.api_key = "myapikey"
|
12
|
-
"""
|
13
|
-
And I define a response for "TestController#index":
|
14
|
-
"""
|
15
|
-
render :inline => '<html><head profile="http://example.com"><%= airbrake_javascript_notifier %></head><body></body></html>'
|
16
|
-
"""
|
17
|
-
And I route "/test/index" to "test#index"
|
18
|
-
And I perform a request to "http://example.com:123/test/index" in the "production" environment
|
19
|
-
Then I should see the notifier JavaScript for the following:
|
20
|
-
| api_key | environment | host |
|
21
|
-
| myapikey | production | api.airbrake.io |
|
22
|
-
And the notifier JavaScript should provide the following errorDefaults:
|
23
|
-
| url | component | action |
|
24
|
-
| http://example.com:123/test/index | test | index |
|
25
|
-
|
26
|
-
Scenario: Include the Javascript notifier when enabled using custom configuration settings
|
27
|
-
When I configure the notifier to use the following configuration lines:
|
28
|
-
"""
|
29
|
-
config.development_environments = []
|
30
|
-
config.api_key = "myapikey!"
|
31
|
-
config.host = "myairbrake.com"
|
32
|
-
config.port = 3001
|
33
|
-
"""
|
34
|
-
And I define a response for "TestController#index":
|
35
|
-
"""
|
36
|
-
render :inline => '<html><head><%= airbrake_javascript_notifier %></head><body></body></html>'
|
37
|
-
"""
|
38
|
-
And I route "/test/index" to "test#index"
|
39
|
-
And I perform a request to "http://example.com:123/test/index"
|
40
|
-
Then I should see the notifier JavaScript for the following:
|
41
|
-
| api_key | environment | host |
|
42
|
-
| myapikey! | test | myairbrake.com:3001 |
|
43
|
-
|
44
|
-
Scenario: Don't include the Javascript notifier by default
|
45
|
-
When I configure the notifier to use the following configuration lines:
|
46
|
-
"""
|
47
|
-
config.api_key = "myapikey!"
|
48
|
-
"""
|
49
|
-
And I define a response for "TestController#index":
|
50
|
-
"""
|
51
|
-
render :inline => "<html><head></head><body></body></html>"
|
52
|
-
"""
|
53
|
-
And I route "/test/index" to "test#index"
|
54
|
-
And I perform a request to "http://example.com:123/test/index"
|
55
|
-
Then I should not see notifier JavaScript
|
56
|
-
|
57
|
-
Scenario: Don't include the Javascript notifier when enabled in non-public environments
|
58
|
-
When I configure the notifier to use the following configuration lines:
|
59
|
-
"""
|
60
|
-
config.api_key = "myapikey!"
|
61
|
-
config.environment_name = 'test'
|
62
|
-
"""
|
63
|
-
And I define a response for "TestController#index":
|
64
|
-
"""
|
65
|
-
render :inline => '<html><head><%= airbrake_javascript_notifier %></head><body></body></html>'
|
66
|
-
"""
|
67
|
-
And I route "/test/index" to "test#index"
|
68
|
-
And I perform a request to "http://example.com:123/test/index" in the "test" environment
|
69
|
-
Then I should not see notifier JavaScript
|
70
|
-
|
71
|
-
Scenario: Use the js_api_key if present
|
72
|
-
When I configure the notifier to use the following configuration lines:
|
73
|
-
"""
|
74
|
-
config.api_key = "myapikey!"
|
75
|
-
config.js_api_key = "myjsapikey!"
|
76
|
-
"""
|
77
|
-
And I define a response for "TestController#index":
|
78
|
-
"""
|
79
|
-
render :inline => '<html><head><%= airbrake_javascript_notifier %></head><body></body></html>'
|
80
|
-
"""
|
81
|
-
And I route "/test/index" to "test#index"
|
82
|
-
And I perform a request to "http://example.com:123/test/index" in the "production" environment
|
83
|
-
Then I should see the notifier JavaScript for the following:
|
84
|
-
| api_key | environment | host |
|
85
|
-
| myjsapikey! | production | api.airbrake.io |
|
86
|
-
|
87
|
-
Scenario: Being careful with user's instance variables
|
88
|
-
When I configure the notifier to use the following configuration lines:
|
89
|
-
"""
|
90
|
-
config.api_key = "myapikey"
|
91
|
-
"""
|
92
|
-
And I define a response for "TestController#index":
|
93
|
-
"""
|
94
|
-
@template = "this is some random instance variable"
|
95
|
-
render :inline => '<html><head><%= airbrake_javascript_notifier %></head><body></body></html>'
|
96
|
-
"""
|
97
|
-
And I route "/test/index" to "test#index"
|
98
|
-
And I perform a request to "http://example.com:123/test/index" in the "production" environment
|
99
|
-
Then I should see the notifier JavaScript for the following:
|
100
|
-
| api_key | environment | host |
|
101
|
-
| myapikey | production | api.airbrake.io |
|
102
|
-
And the notifier JavaScript should provide the following errorDefaults:
|
103
|
-
| url | component | action |
|
104
|
-
| http://example.com:123/test/index | test | index |
|
@@ -1,85 +0,0 @@
|
|
1
|
-
module Airbrake
|
2
|
-
module Rails
|
3
|
-
module JavascriptNotifier
|
4
|
-
def self.included(base) #:nodoc:
|
5
|
-
base.send :helper_method, :airbrake_javascript_notifier
|
6
|
-
base.send :helper_method, :airbrake_javascript_loader
|
7
|
-
base.send :helper_method, :airbrake_javascript_configuration
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def airbrake_javascript_notifier
|
13
|
-
warn '[DEPRECATION] `airbrake_javascript_notifier` is deprecated and will no longer be supported in v4.0.0. /
|
14
|
-
Please use the official Airbrake JavaScript Notifier - https://github.com/airbrake/airbrake-js'
|
15
|
-
if Airbrake.configuration.public?
|
16
|
-
airbrake_javascript_loader + airbrake_javascript_configuration
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def airbrake_javascript_loader
|
21
|
-
if Airbrake.configuration.public?
|
22
|
-
path = File.join File.dirname(__FILE__), '..', '..', 'templates', 'javascript_notifier_loader'
|
23
|
-
|
24
|
-
_airbrake_render_part path
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def airbrake_javascript_configuration
|
29
|
-
if Airbrake.configuration.public?
|
30
|
-
path = File.join File.dirname(__FILE__), '..', '..', 'templates', 'javascript_notifier_configuration'
|
31
|
-
|
32
|
-
options = {
|
33
|
-
:api_key => Airbrake.configuration.js_api_key,
|
34
|
-
:environment => Airbrake.configuration.environment_name,
|
35
|
-
:action_name => action_name,
|
36
|
-
:controller_name => controller_name,
|
37
|
-
:url => request.url
|
38
|
-
}
|
39
|
-
|
40
|
-
_airbrake_render_part path, options
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
protected
|
45
|
-
attr_reader :template
|
46
|
-
|
47
|
-
def _airbrake_render_part(path, locals={})
|
48
|
-
locals[:host] = _airbrake_host
|
49
|
-
|
50
|
-
options = {
|
51
|
-
:file => path,
|
52
|
-
:layout => false,
|
53
|
-
:use_full_path => false,
|
54
|
-
:handlers => [:erb],
|
55
|
-
:locals => locals
|
56
|
-
}
|
57
|
-
|
58
|
-
result = _airbrake_render_template options
|
59
|
-
|
60
|
-
if result.respond_to?(:html_safe)
|
61
|
-
result.html_safe
|
62
|
-
else
|
63
|
-
result
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def _airbrake_render_template(options)
|
68
|
-
case template
|
69
|
-
when ActionView::Template
|
70
|
-
template.render options
|
71
|
-
else
|
72
|
-
render_to_string options
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def _airbrake_host
|
77
|
-
host = Airbrake.configuration.host.dup
|
78
|
-
port = Airbrake.configuration.port
|
79
|
-
host << ":#{port}" unless [80, 443].include?(port)
|
80
|
-
|
81
|
-
host
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<%= javascript_tag %Q{
|
2
|
-
try {
|
3
|
-
window.Airbrake = (typeof(Airbrake) == 'undefined' && typeof(Hoptoad) != 'undefined') ? Hoptoad : Airbrake
|
4
|
-
Airbrake.setKey('#{api_key}');
|
5
|
-
Airbrake.setHost('#{host}');
|
6
|
-
Airbrake.setEnvironment('#{environment}');
|
7
|
-
Airbrake.setErrorDefaults({ url: "#{escape_javascript url}", component: "#{controller_name}", action: "#{action_name}" });
|
8
|
-
} catch (e) {
|
9
|
-
window.onerror = null;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
%>
|
@@ -1,6 +0,0 @@
|
|
1
|
-
<%= javascript_tag %Q{
|
2
|
-
(function(){
|
3
|
-
var notifierJsScheme = (("https:" == document.location.protocol) ? "https://" : "http://");
|
4
|
-
document.write(unescape("%3Cscript src='" + notifierJsScheme + "#{host}/javascripts/notifier.js' type='text/javascript'%3E%3C/script%3E"));
|
5
|
-
})();
|
6
|
-
}%>
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'airbrake/rails/javascript_notifier'
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
class JavascriptNotifierTest < Test::Unit::TestCase
|
5
|
-
module FakeRenderer
|
6
|
-
def javascript_tag(text)
|
7
|
-
"<script>#{text}</script>"
|
8
|
-
end
|
9
|
-
def escape_javascript(text)
|
10
|
-
"ESC#{text}ESC"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class FakeController
|
15
|
-
def self.helper_method(*args)
|
16
|
-
end
|
17
|
-
|
18
|
-
include Airbrake::Rails::JavascriptNotifier
|
19
|
-
|
20
|
-
def action_name
|
21
|
-
"action"
|
22
|
-
end
|
23
|
-
|
24
|
-
def controller_name
|
25
|
-
"controller"
|
26
|
-
end
|
27
|
-
|
28
|
-
def request
|
29
|
-
@request ||= OpenStruct.new
|
30
|
-
end
|
31
|
-
|
32
|
-
def render_to_string(options)
|
33
|
-
context = OpenStruct.new(options[:locals])
|
34
|
-
context.extend(FakeRenderer)
|
35
|
-
context.instance_eval do
|
36
|
-
erb = ERB.new(IO.read(options[:file]))
|
37
|
-
erb.result(binding)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
should "make sure escape_javacript is called on the request.url" do
|
43
|
-
Airbrake.configure do
|
44
|
-
end
|
45
|
-
controller = FakeController.new
|
46
|
-
controller.request.url = "bad_javascript"
|
47
|
-
assert controller.send(:airbrake_javascript_notifier)['"ESCbad_javascriptESC"']
|
48
|
-
assert ! controller.send(:airbrake_javascript_notifier)['"bad_javascript"']
|
49
|
-
end
|
50
|
-
|
51
|
-
should "not raise exceptions for the non-public requests" do
|
52
|
-
Airbrake::Configuration.any_instance.stubs(:public? => false)
|
53
|
-
controller = FakeController.new
|
54
|
-
assert_nothing_raised { controller.send(:airbrake_javascript_notifier) }
|
55
|
-
end
|
56
|
-
end
|