-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
118 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Telebugs | ||
class Middleware | ||
class IgnoreEnvironments < Telebugs::Middleware | ||
def initialize(current_env, ignore_envs) | ||
@current_env = current_env | ||
@ignore_envs = ignore_envs | ||
end | ||
|
||
def call(report) | ||
report.ignored = @ignore_envs.include?(@current_env) | ||
end | ||
|
||
def weight | ||
-1000 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,5 +35,9 @@ def then(...) | |
def rescue(...) | ||
@future.rescue(...) | ||
end | ||
|
||
def state | ||
@future.state | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class TestIgnoreEnvironments < Minitest::Test | ||
def test_ignore_environments_when_env_matches | ||
report = Telebugs::Report.new(StandardError.new("test error")) | ||
Telebugs::Middleware::IgnoreEnvironments.new("production", ["production"]).call(report) | ||
|
||
assert report.ignored | ||
end | ||
|
||
def test_ignore_environments_when_env_does_not_match | ||
report = Telebugs::Report.new(StandardError.new("test error")) | ||
Telebugs::Middleware::IgnoreEnvironments.new("development", ["production"]).call(report) | ||
|
||
refute report.ignored | ||
end | ||
|
||
def test_weight | ||
assert_equal(-1000, Telebugs::Middleware::IgnoreEnvironments.new("production", []).weight) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters