airbrake-ruby 1.3.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26dc2614a9b7f3853bf504c7bf59e87844c0d319
4
- data.tar.gz: ab91d35ff054319c4c15b97f7286cb80748410b7
3
+ metadata.gz: 872e5dbd662f107ff1edc407c3e0464816884252
4
+ data.tar.gz: ad9561bb25b64fe45eaab08f8e53860dd26d92dd
5
5
  SHA512:
6
- metadata.gz: 8be384f5265c4232b4ef0f4239b41837ef9b5974bb95361a5d554a100d393a37314aa7fbe7e586953159f3ab7dc860a02938be41a9bc2cf4dd7c5ce015cd6400
7
- data.tar.gz: 6b1086df37f5f2dbbf29f09caa4e3b1205bc41e323ec046868d528d1fa07f2e47a9de078f4878d6bf8d2bb085a3efbc9c401be3fba51d7de09de63c468ef39f4
6
+ metadata.gz: 7026eac93af682eb7885c62ca608507cc66273da5341fda6d145ad0b692dfa866195ffb3331cea33e8b276199608b0f706fb67db08a64ba8477f0300a9557ecf
7
+ data.tar.gz: 2f6d1b674f9342088ddb4cc0231d5fc923814a99077131ab67abcf121d66ac96dccbc4eaad3a16dc758148dd4e8caffec193c08436a8dac356fd1827220ea32b
@@ -125,6 +125,22 @@ module Airbrake
125
125
  self
126
126
  end
127
127
 
128
+ ##
129
+ # @return [Boolean] true if the config meets the requirements, false
130
+ # otherwise
131
+ def valid?
132
+ return true if ignored_environment?
133
+ return false unless project_id.is_a?(Integer)
134
+ project_key.is_a?(String) && !project_key.empty?
135
+ end
136
+
137
+ ##
138
+ # @return [Boolean] true if the config ignores current environment, false
139
+ # otherwise
140
+ def ignored_environment?
141
+ ignore_environments.include?(environment)
142
+ end
143
+
128
144
  private
129
145
 
130
146
  def set_option(option, value)
@@ -30,7 +30,7 @@ module Airbrake
30
30
  def initialize(user_config)
31
31
  @config = (user_config.is_a?(Config) ? user_config : Config.new(user_config))
32
32
 
33
- unless [@config.project_id, @config.project_key].all?
33
+ unless @config.valid?
34
34
  raise Airbrake::Error, 'both :project_id and :project_key are required'
35
35
  end
36
36
 
@@ -143,9 +143,7 @@ module Airbrake
143
143
  end
144
144
 
145
145
  def send_notice(exception, params, sender = default_sender)
146
- if @config.ignore_environments.any?
147
- return if @config.ignore_environments.include?(@config.environment)
148
- end
146
+ return if @config.ignored_environment?
149
147
 
150
148
  notice = build_notice(exception, params)
151
149
  @filter_chain.refine(notice)
@@ -3,5 +3,5 @@
3
3
  module Airbrake
4
4
  ##
5
5
  # @return [String] the library version
6
- AIRBRAKE_RUBY_VERSION = '1.3.2'.freeze
6
+ AIRBRAKE_RUBY_VERSION = '1.4.0'.freeze
7
7
  end
data/spec/config_spec.rb CHANGED
@@ -76,4 +76,75 @@ RSpec.describe Airbrake::Config do
76
76
  end
77
77
  end
78
78
  end
79
+
80
+ describe "#valid?" do
81
+ context "when project_id is nil" do
82
+ it "returns false" do
83
+ config.project_id = nil
84
+ config.project_key = '123'
85
+
86
+ expect(config).not_to be_valid
87
+ end
88
+ end
89
+
90
+ context "when project_key is nil" do
91
+ it "returns false" do
92
+ config.project_id = 123
93
+ config.project_key = nil
94
+
95
+ expect(config).not_to be_valid
96
+ end
97
+ end
98
+
99
+ context "when the current environment is ignored" do
100
+ context "and when the notifier misconfigures configure project_key & project_id" do
101
+ it "returns true" do
102
+ config.project_id = Object.new
103
+ config.project_key = Object.new
104
+ config.environment = :bingo
105
+ config.ignore_environments = [:bingo]
106
+
107
+ expect(config).to be_valid
108
+ end
109
+ end
110
+
111
+ context "and when the notifier configures project_key & project_id" do
112
+ it "returns true" do
113
+ config.project_id = 123
114
+ config.project_key = '321'
115
+ config.environment = :bingo
116
+ config.ignore_environments = [:bingo]
117
+
118
+ expect(config).to be_valid
119
+ end
120
+ end
121
+ end
122
+
123
+ context "when the project_id value is not an Integer" do
124
+ it "returns false" do
125
+ config.project_id = '123'
126
+ config.project_key = '321'
127
+
128
+ expect(config).not_to be_valid
129
+ end
130
+ end
131
+
132
+ context "when the project_key value is not a String" do
133
+ it "returns false" do
134
+ config.project_id = 123
135
+ config.project_key = 321
136
+
137
+ expect(config).not_to be_valid
138
+ end
139
+ end
140
+
141
+ context "when the project_key value is an empty String" do
142
+ it "returns false" do
143
+ config.project_id = 123
144
+ config.project_key = ''
145
+
146
+ expect(config).not_to be_valid
147
+ end
148
+ end
149
+ end
79
150
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-27 00:00:00.000000000 Z
11
+ date: 2016-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec