raygun4ruby 3.2.0 → 3.2.5.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +21 -18
  3. data/.rspec +1 -1
  4. data/.travis.yml +20 -12
  5. data/CHANGELOG.md +130 -117
  6. data/Gemfile +4 -4
  7. data/LICENSE.txt +22 -22
  8. data/README.md +420 -420
  9. data/Rakefile +27 -27
  10. data/examples/sinatras_raygun.rb +17 -17
  11. data/lib/generators/raygun/install_generator.rb +26 -26
  12. data/lib/raygun.rb +179 -179
  13. data/lib/raygun/affected_user.rb +59 -59
  14. data/lib/raygun/breadcrumbs.rb +34 -34
  15. data/lib/raygun/breadcrumbs/breadcrumb.rb +34 -34
  16. data/lib/raygun/breadcrumbs/store.rb +86 -86
  17. data/lib/raygun/client.rb +308 -303
  18. data/lib/raygun/configuration.rb +194 -194
  19. data/lib/raygun/error.rb +10 -10
  20. data/lib/raygun/javascript_tracker.rb +42 -42
  21. data/lib/raygun/middleware/breadcrumbs_store_initializer.rb +19 -19
  22. data/lib/raygun/middleware/javascript_exception_tracking.rb +32 -32
  23. data/lib/raygun/middleware/rack_exception_interceptor.rb +18 -18
  24. data/lib/raygun/middleware/rails_insert_affected_user.rb +26 -26
  25. data/lib/raygun/railtie.rb +39 -39
  26. data/lib/raygun/services/apply_whitelist_filter_to_payload.rb +27 -27
  27. data/lib/raygun/sidekiq.rb +71 -67
  28. data/lib/raygun/version.rb +3 -3
  29. data/lib/raygun4ruby.rb +1 -1
  30. data/lib/resque/failure/raygun.rb +25 -25
  31. data/lib/tasks/raygun.tasks +7 -7
  32. data/raygun4ruby.gemspec +45 -45
  33. data/spec/dummy/.gitignore +17 -0
  34. data/spec/dummy/Gemfile +47 -0
  35. data/spec/dummy/README.rdoc +28 -0
  36. data/spec/dummy/Rakefile +6 -6
  37. data/spec/dummy/app/assets/config/manifest.js +3 -3
  38. data/spec/dummy/app/assets/javascripts/application.js +13 -15
  39. data/spec/dummy/app/assets/stylesheets/application.css +15 -15
  40. data/spec/dummy/app/controllers/application_controller.rb +5 -2
  41. data/spec/dummy/app/controllers/home_controller.rb +4 -4
  42. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  43. data/spec/dummy/app/{assets/javascripts/channels → mailers}/.keep +0 -0
  44. data/spec/dummy/{storage → app/models}/.keep +0 -0
  45. data/spec/dummy/app/views/home/index.html.erb +3 -3
  46. data/spec/dummy/app/views/home/index.json.erb +1 -1
  47. data/spec/dummy/app/views/layouts/application.html.erb +14 -15
  48. data/spec/dummy/bin/bundle +3 -3
  49. data/spec/dummy/bin/rails +9 -4
  50. data/spec/dummy/bin/rake +9 -4
  51. data/spec/dummy/bin/setup +29 -36
  52. data/spec/dummy/bin/spring +17 -0
  53. data/spec/dummy/config.ru +4 -5
  54. data/spec/dummy/config/application.rb +26 -18
  55. data/spec/dummy/config/boot.rb +3 -5
  56. data/spec/dummy/config/database.yml +25 -25
  57. data/spec/dummy/config/environment.rb +5 -5
  58. data/spec/dummy/config/environments/development.rb +41 -61
  59. data/spec/dummy/config/environments/production.rb +79 -94
  60. data/spec/dummy/config/initializers/assets.rb +11 -14
  61. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  62. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -5
  63. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  64. data/spec/dummy/config/initializers/inflections.rb +16 -16
  65. data/spec/dummy/config/initializers/mime_types.rb +4 -4
  66. data/spec/dummy/config/initializers/session_store.rb +3 -0
  67. data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +10 -0
  68. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  69. data/spec/dummy/config/locales/en.yml +23 -33
  70. data/spec/dummy/config/routes.rb +58 -3
  71. data/spec/dummy/config/secrets.yml +22 -0
  72. data/spec/dummy/db/seeds.rb +7 -0
  73. data/spec/dummy/{db/test.sqlite3 → lib/tasks/.keep} +0 -0
  74. data/spec/dummy/public/404.html +67 -67
  75. data/spec/dummy/public/422.html +67 -67
  76. data/spec/dummy/public/500.html +66 -66
  77. data/spec/dummy/public/robots.txt +5 -0
  78. data/spec/dummy/{public/apple-touch-icon-precomposed.png → vendor/assets/javascripts/.keep} +0 -0
  79. data/spec/dummy/{public/apple-touch-icon.png → vendor/assets/stylesheets/.keep} +0 -0
  80. data/spec/features/javascript_spec.rb +48 -48
  81. data/spec/rails_helper.rb +4 -4
  82. data/spec/raygun/breadcrumbs/breadcrumb_spec.rb +171 -171
  83. data/spec/raygun/breadcrumbs/store_spec.rb +170 -170
  84. data/spec/raygun/raygun_spec.rb +47 -47
  85. data/spec/services/apply_whitelist_filter_to_payload_spec.rb +251 -251
  86. data/spec/spec_helper.rb +24 -24
  87. data/spec/support/fake_logger.rb +17 -17
  88. data/test/integration/client_test.rb +19 -19
  89. data/test/test_helper.rb +72 -72
  90. data/test/unit/affected_user_test.rb +136 -136
  91. data/test/unit/client_test.rb +812 -790
  92. data/test/unit/configuration_test.rb +206 -206
  93. data/test/unit/raygun_test.rb +25 -25
  94. data/test/unit/resque_failure_test.rb +24 -24
  95. data/test/unit/sidekiq_failure_test.rb +32 -32
  96. metadata +36 -49
  97. data/lib/raygun/testable.rb +0 -23
  98. data/spec/dummy/.ruby-version +0 -1
  99. data/spec/dummy/app/assets/javascripts/cable.js +0 -13
  100. data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
  101. data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
  102. data/spec/dummy/app/jobs/application_job.rb +0 -2
  103. data/spec/dummy/app/mailers/application_mailer.rb +0 -4
  104. data/spec/dummy/app/models/application_record.rb +0 -3
  105. data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
  106. data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
  107. data/spec/dummy/bin/update +0 -31
  108. data/spec/dummy/bin/yarn +0 -11
  109. data/spec/dummy/config/cable.yml +0 -10
  110. data/spec/dummy/config/environments/test.rb +0 -46
  111. data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
  112. data/spec/dummy/config/initializers/content_security_policy.rb +0 -25
  113. data/spec/dummy/config/puma.rb +0 -34
  114. data/spec/dummy/config/spring.rb +0 -6
  115. data/spec/dummy/config/storage.yml +0 -34
  116. data/spec/dummy/db/schema.rb +0 -15
  117. data/spec/dummy/package.json +0 -5
data/spec/spec_helper.rb CHANGED
@@ -1,24 +1,24 @@
1
- #require 'rubygems'
2
-
3
- require 'timecop'
4
- require 'webmock/rspec'
5
-
6
- # Coverage
7
- require 'simplecov'
8
- SimpleCov.start do
9
- add_filter '/spec/'
10
- end
11
-
12
- require 'support/fake_logger'
13
-
14
- RSpec.configure do |config|
15
- # Enable flags like --only-failures and --next-failure
16
- # config.example_status_persistence_file_path = ".rspec_status"
17
-
18
- # Disable RSpec exposing methods globally on `Module` and `main`
19
- # config.disable_monkey_patching!
20
-
21
- config.expect_with :rspec do |c|
22
- c.syntax = :expect
23
- end
24
- end
1
+ #require 'rubygems'
2
+
3
+ require 'timecop'
4
+ require 'webmock/rspec'
5
+
6
+ # Coverage
7
+ require 'simplecov'
8
+ SimpleCov.start do
9
+ add_filter '/spec/'
10
+ end
11
+
12
+ require 'support/fake_logger'
13
+
14
+ RSpec.configure do |config|
15
+ # Enable flags like --only-failures and --next-failure
16
+ # config.example_status_persistence_file_path = ".rspec_status"
17
+
18
+ # Disable RSpec exposing methods globally on `Module` and `main`
19
+ # config.disable_monkey_patching!
20
+
21
+ config.expect_with :rspec do |c|
22
+ c.syntax = :expect
23
+ end
24
+ end
@@ -1,17 +1,17 @@
1
- class FakeLogger
2
- def initialize
3
- @logger = StringIO.new
4
- end
5
-
6
- def info(message)
7
- @logger.write(message)
8
- end
9
-
10
- def reset
11
- @logger.string = ""
12
- end
13
-
14
- def get
15
- @logger.string
16
- end
17
- end
1
+ class FakeLogger
2
+ def initialize
3
+ @logger = StringIO.new
4
+ end
5
+
6
+ def info(message)
7
+ @logger.write(message)
8
+ end
9
+
10
+ def reset
11
+ @logger.string = ""
12
+ end
13
+
14
+ def get
15
+ @logger.string
16
+ end
17
+ end
@@ -1,20 +1,20 @@
1
- require_relative "../test_helper.rb"
2
-
3
- class ClientTest < Raygun::IntegrationTest
4
-
5
- class InnocentTestException < StandardError
6
- def message
7
- "I am nothing but a test exception"
8
- end
9
- end
10
-
11
- def test_sending_a_sample_exception
12
- begin
13
- raise InnocentTestException.new
14
- rescue InnocentTestException => e
15
- response = Raygun.track_exception(e)
16
- assert_equal 202, response.code, "Raygun Request Failed: #{response.inspect}"
17
- end
18
- end
19
-
1
+ require_relative "../test_helper.rb"
2
+
3
+ class ClientTest < Raygun::IntegrationTest
4
+
5
+ class InnocentTestException < StandardError
6
+ def message
7
+ "I am nothing but a test exception"
8
+ end
9
+ end
10
+
11
+ def test_sending_a_sample_exception
12
+ begin
13
+ raise InnocentTestException.new
14
+ rescue InnocentTestException => e
15
+ response = Raygun.track_exception(e)
16
+ assert_equal 202, response.code, "Raygun Request Failed: #{response.inspect}"
17
+ end
18
+ end
19
+
20
20
  end
data/test/test_helper.rb CHANGED
@@ -1,72 +1,72 @@
1
- ENV['RACK_ENV'] = 'test'
2
- require_relative "../lib/raygun.rb"
3
- require "minitest/autorun"
4
- require "minitest/pride"
5
- require "timecop"
6
- require "mocha/mini_test"
7
- require 'stringio'
8
- require 'webmock/minitest'
9
-
10
- class FakeLogger
11
- def initialize
12
- @logger = StringIO.new
13
- end
14
-
15
- def info(message)
16
- @logger.write(message)
17
- end
18
-
19
- def reset
20
- @logger.string = ""
21
- end
22
-
23
- def get
24
- @logger.string
25
- end
26
- end
27
-
28
- class NoApiKey < StandardError; end
29
-
30
- class Raygun::IntegrationTest < Minitest::Unit::TestCase
31
-
32
- def setup
33
- Raygun.setup do |config|
34
- config.api_key = File.open(File.expand_path("~/.raygun4ruby-test-key"), "rb").read
35
- config.version = Raygun::VERSION
36
- end
37
-
38
- rescue Errno::ENOENT
39
- raise NoApiKey.new("Place a valid Raygun API key into ~/.raygun4ruby-test-key to run integration tests") unless api_key
40
- end
41
-
42
- def teardown
43
- end
44
-
45
- end
46
-
47
- class Raygun::UnitTest < MiniTest::Unit::TestCase
48
-
49
- def setup
50
- Raygun.configuration.api_key = "test api key"
51
- end
52
-
53
- def teardown
54
- reset_configuration
55
- end
56
-
57
- def fake_successful_entry
58
- stub_request(:post, 'https://api.raygun.io/entries').to_return(status: 202)
59
- end
60
-
61
- def reset_configuration
62
- Raygun.configuration = Raygun::Configuration.new
63
- end
64
-
65
- def setup_logging
66
- logger = FakeLogger.new
67
- Raygun.configuration.debug = true
68
- Raygun.configuration.logger = logger
69
-
70
- logger
71
- end
72
- end
1
+ ENV['RACK_ENV'] = 'test'
2
+ require_relative "../lib/raygun.rb"
3
+ require "minitest/autorun"
4
+ require "minitest/pride"
5
+ require "timecop"
6
+ require "mocha/minitest"
7
+ require 'stringio'
8
+ require 'webmock/minitest'
9
+
10
+ class FakeLogger
11
+ def initialize
12
+ @logger = StringIO.new
13
+ end
14
+
15
+ def info(message)
16
+ @logger.write(message)
17
+ end
18
+
19
+ def reset
20
+ @logger.string = ""
21
+ end
22
+
23
+ def get
24
+ @logger.string
25
+ end
26
+ end
27
+
28
+ class NoApiKey < StandardError; end
29
+
30
+ class Raygun::IntegrationTest < Minitest::Test
31
+
32
+ def setup
33
+ Raygun.setup do |config|
34
+ config.api_key = File.open(File.expand_path("~/.raygun4ruby-test-key"), "rb").read
35
+ config.version = Raygun::VERSION
36
+ end
37
+
38
+ rescue Errno::ENOENT
39
+ raise NoApiKey.new("Place a valid Raygun API key into ~/.raygun4ruby-test-key to run integration tests") unless api_key
40
+ end
41
+
42
+ def teardown
43
+ end
44
+
45
+ end
46
+
47
+ class Raygun::UnitTest < MiniTest::Test
48
+
49
+ def setup
50
+ Raygun.configuration.api_key = "test api key"
51
+ end
52
+
53
+ def teardown
54
+ reset_configuration
55
+ end
56
+
57
+ def fake_successful_entry
58
+ stub_request(:post, 'https://api.raygun.com/entries').to_return(status: 202)
59
+ end
60
+
61
+ def reset_configuration
62
+ Raygun.configuration = Raygun::Configuration.new
63
+ end
64
+
65
+ def setup_logging
66
+ logger = FakeLogger.new
67
+ Raygun.configuration.debug = true
68
+ Raygun.configuration.logger = logger
69
+
70
+ logger
71
+ end
72
+ end
@@ -1,136 +1,136 @@
1
- require_relative "../test_helper.rb"
2
- require 'ostruct'
3
- require 'raygun/middleware/rails_insert_affected_user'
4
-
5
- class AffectedUserTest < Raygun::UnitTest
6
-
7
- class TestException < StandardError; end
8
-
9
- class MockController
10
-
11
- def user_with_email
12
- OpenStruct.new(id: 123, email: "testemail@something.com")
13
- end
14
-
15
- def user_with_login
16
- OpenStruct.new(login: "topsecret")
17
- end
18
-
19
- def user_with_full_details
20
- OpenStruct.new(id: 123, email: "testemail@something.com", first_name: "Taylor", last_name: "Lodge")
21
- end
22
-
23
- def user_as_string
24
- "some-string-identifier"
25
- end
26
-
27
- def no_logged_in_user
28
- end
29
-
30
- private
31
-
32
- def private_current_user
33
- user_with_email
34
- end
35
-
36
- end
37
-
38
- class MockApp
39
- attr_accessor :env
40
-
41
- def call(env)
42
- @env = env
43
- raise TestException.new
44
- end
45
- end
46
-
47
- def setup
48
- super
49
- @client = Raygun::Client.new
50
- fake_successful_entry
51
-
52
- @app = MockApp.new
53
- @controller = MockController.new
54
- @middleware = Raygun::Middleware::RailsInsertAffectedUser.new(@app)
55
- end
56
-
57
- def test_inserting_user_object_with_email
58
- Raygun.configuration.affected_user_method = :user_with_email
59
- assert @controller.respond_to?(Raygun.configuration.affected_user_method)
60
-
61
- begin
62
- @middleware.call("action_controller.instance" => @controller)
63
- rescue TestException
64
- user_hash = { :identifier => 123, :email => "testemail@something.com", :isAnonymous => false }
65
- assert_equal user_hash, @app.env["raygun.affected_user"]
66
- end
67
- end
68
-
69
- def test_changing_method_mapping
70
- Raygun.configuration.affected_user_method = :user_with_login
71
- Raygun.configuration.affected_user_mapping = {
72
- identifier: :login
73
- }
74
-
75
- assert @controller.respond_to?(Raygun.configuration.affected_user_method)
76
-
77
- begin
78
- @middleware.call("action_controller.instance" => @controller)
79
- rescue TestException
80
- user_hash = { :identifier => "topsecret", :isAnonymous => false }
81
- assert_equal user_hash, @app.env["raygun.affected_user"]
82
- end
83
- end
84
-
85
- def test_inserting_user_as_plain_string
86
- Raygun.configuration.affected_user_method = :user_as_string
87
- assert @controller.respond_to?(Raygun.configuration.affected_user_method)
88
-
89
- begin
90
- @middleware.call("action_controller.instance" => @controller)
91
- rescue TestException
92
- user_hash = { :identifier => "some-string-identifier", :isAnonymous => true }
93
- assert_equal user_hash, @app.env["raygun.affected_user"]
94
- end
95
- end
96
-
97
- def test_with_a_nil_user
98
- Raygun.configuration.affected_user_method = :no_logged_in_user
99
- assert @controller.respond_to?(Raygun.configuration.affected_user_method)
100
-
101
- begin
102
- @middleware.call("action_controller.instance" => @controller)
103
- rescue TestException
104
- user_hash = { :isAnonymous => true }
105
- assert_equal user_hash, @app.env["raygun.affected_user"]
106
- end
107
- end
108
-
109
- def test_with_private_method
110
- Raygun.configuration.affected_user_method = :private_current_user
111
- assert @controller.respond_to?(Raygun.configuration.affected_user_method, true)
112
-
113
- begin
114
- @middleware.call("action_controller.instance" => @controller)
115
- rescue TestException
116
- user_hash = {:isAnonymous=>false, :identifier=>123, :email=>"testemail@something.com"}
117
- assert_equal user_hash, @app.env["raygun.affected_user"]
118
- end
119
- end
120
-
121
- def test_with_proc_for_mapping
122
- Raygun.configuration.affected_user_method = :user_with_full_details
123
- Raygun.configuration.affected_user_mapping = Raygun::AffectedUser::DEFAULT_MAPPING.merge({
124
- full_name: ->(user) { "#{user.first_name} #{user.last_name}" }
125
- })
126
-
127
- assert @controller.respond_to?(Raygun.configuration.affected_user_method, true)
128
-
129
- begin
130
- @middleware.call("action_controller.instance" => @controller)
131
- rescue TestException
132
- user_hash = {:isAnonymous=>false, :identifier=>123, :email=>"testemail@something.com", :fullName => "Taylor Lodge", :firstName => "Taylor"}
133
- assert_equal user_hash, @app.env["raygun.affected_user"]
134
- end
135
- end
136
- end
1
+ require_relative "../test_helper.rb"
2
+ require 'ostruct'
3
+ require 'raygun/middleware/rails_insert_affected_user'
4
+
5
+ class AffectedUserTest < Raygun::UnitTest
6
+
7
+ class TestException < StandardError; end
8
+
9
+ class MockController
10
+
11
+ def user_with_email
12
+ OpenStruct.new(id: 123, email: "testemail@something.com")
13
+ end
14
+
15
+ def user_with_login
16
+ OpenStruct.new(login: "topsecret")
17
+ end
18
+
19
+ def user_with_full_details
20
+ OpenStruct.new(id: 123, email: "testemail@something.com", first_name: "Taylor", last_name: "Lodge")
21
+ end
22
+
23
+ def user_as_string
24
+ "some-string-identifier"
25
+ end
26
+
27
+ def no_logged_in_user
28
+ end
29
+
30
+ private
31
+
32
+ def private_current_user
33
+ user_with_email
34
+ end
35
+
36
+ end
37
+
38
+ class MockApp
39
+ attr_accessor :env
40
+
41
+ def call(env)
42
+ @env = env
43
+ raise TestException.new
44
+ end
45
+ end
46
+
47
+ def setup
48
+ super
49
+ @client = Raygun::Client.new
50
+ fake_successful_entry
51
+
52
+ @app = MockApp.new
53
+ @controller = MockController.new
54
+ @middleware = Raygun::Middleware::RailsInsertAffectedUser.new(@app)
55
+ end
56
+
57
+ def test_inserting_user_object_with_email
58
+ Raygun.configuration.affected_user_method = :user_with_email
59
+ assert @controller.respond_to?(Raygun.configuration.affected_user_method)
60
+
61
+ begin
62
+ @middleware.call("action_controller.instance" => @controller)
63
+ rescue TestException
64
+ user_hash = { :identifier => 123, :email => "testemail@something.com", :isAnonymous => false }
65
+ assert_equal user_hash, @app.env["raygun.affected_user"]
66
+ end
67
+ end
68
+
69
+ def test_changing_method_mapping
70
+ Raygun.configuration.affected_user_method = :user_with_login
71
+ Raygun.configuration.affected_user_mapping = {
72
+ identifier: :login
73
+ }
74
+
75
+ assert @controller.respond_to?(Raygun.configuration.affected_user_method)
76
+
77
+ begin
78
+ @middleware.call("action_controller.instance" => @controller)
79
+ rescue TestException
80
+ user_hash = { :identifier => "topsecret", :isAnonymous => false }
81
+ assert_equal user_hash, @app.env["raygun.affected_user"]
82
+ end
83
+ end
84
+
85
+ def test_inserting_user_as_plain_string
86
+ Raygun.configuration.affected_user_method = :user_as_string
87
+ assert @controller.respond_to?(Raygun.configuration.affected_user_method)
88
+
89
+ begin
90
+ @middleware.call("action_controller.instance" => @controller)
91
+ rescue TestException
92
+ user_hash = { :identifier => "some-string-identifier", :isAnonymous => true }
93
+ assert_equal user_hash, @app.env["raygun.affected_user"]
94
+ end
95
+ end
96
+
97
+ def test_with_a_nil_user
98
+ Raygun.configuration.affected_user_method = :no_logged_in_user
99
+ assert @controller.respond_to?(Raygun.configuration.affected_user_method)
100
+
101
+ begin
102
+ @middleware.call("action_controller.instance" => @controller)
103
+ rescue TestException
104
+ user_hash = { :isAnonymous => true }
105
+ assert_equal user_hash, @app.env["raygun.affected_user"]
106
+ end
107
+ end
108
+
109
+ def test_with_private_method
110
+ Raygun.configuration.affected_user_method = :private_current_user
111
+ assert @controller.respond_to?(Raygun.configuration.affected_user_method, true)
112
+
113
+ begin
114
+ @middleware.call("action_controller.instance" => @controller)
115
+ rescue TestException
116
+ user_hash = {:isAnonymous=>false, :identifier=>123, :email=>"testemail@something.com"}
117
+ assert_equal user_hash, @app.env["raygun.affected_user"]
118
+ end
119
+ end
120
+
121
+ def test_with_proc_for_mapping
122
+ Raygun.configuration.affected_user_method = :user_with_full_details
123
+ Raygun.configuration.affected_user_mapping = Raygun::AffectedUser::DEFAULT_MAPPING.merge({
124
+ full_name: ->(user) { "#{user.first_name} #{user.last_name}" }
125
+ })
126
+
127
+ assert @controller.respond_to?(Raygun.configuration.affected_user_method, true)
128
+
129
+ begin
130
+ @middleware.call("action_controller.instance" => @controller)
131
+ rescue TestException
132
+ user_hash = {:isAnonymous=>false, :identifier=>123, :email=>"testemail@something.com", :fullName => "Taylor Lodge", :firstName => "Taylor"}
133
+ assert_equal user_hash, @app.env["raygun.affected_user"]
134
+ end
135
+ end
136
+ end