Skip to content

Commit

Permalink
Test that the ReporterInfo middleware is included
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrylo committed Jun 23, 2024
1 parent 9681eb3 commit 8b47aa3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/telebugs/middleware/test_reporter_info.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require "test_helper"

class Telebugs::Rails::Middleware::TestReporterInfo < Minitest::Test
def test_reporter_info_is_attached_to_report
middleware = Telebugs::Rails::Middleware::ReporterInfo.new

report = Telebugs::Report.new(StandardError.new("test error"))
middleware.call(report)

assert_equal 2, report.data[:reporters].size

r = report.data[:reporters].last

assert_equal "telebugs-rails", r[:library][:name]
assert_equal Telebugs::Rails::VERSION, r[:library][:version]
assert_equal "Rails", r[:platform][:name]
assert_equal Rails.version, r[:platform][:version]
end
end
7 changes: 7 additions & 0 deletions test/telebugs/test_railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,11 @@ def test_report_errors_middleware_inserted_after_debug_exceptions

assert_equal "ActionDispatch::DebugExceptions", middlewares[own_idx - 1]
end

def test_telebugs_is_configured_with_correct_middlewares
middlewares = Telebugs.config.middleware.middlewares.map(&:class)

assert_includes middlewares, Telebugs::Rails::Middleware::IgnoreDevEnv
assert_includes middlewares, Telebugs::Rails::Middleware::ReporterInfo
end
end

0 comments on commit 8b47aa3

Please sign in to comment.