Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 234 lines (201 sloc) 7.822 kB
0400c67 @grosser make all tests runnable via ruby test_file.rb by loading the helper a…
grosser authored
1 require File.expand_path '../helper', __FILE__
e8f7ae2 @qrush Cleaning up whitespace issues and splitting the test suite up
qrush authored
2
00770fa @qrush Adding support for Rails 1.2.6
qrush authored
3 class ConfigurationTest < Test::Unit::TestCase
568a973 Moved code out of the HoptoadNotifier module and into the Notice, Con…
Joe Ferris authored
4
5 include DefinesConstants
6
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
7 should "provide default values" do
8 assert_config_default :proxy_host, nil
9 assert_config_default :proxy_port, nil
10 assert_config_default :proxy_user, nil
11 assert_config_default :proxy_pass, nil
6e564a9 Merging api v2 changes
Joe Ferris authored
12 assert_config_default :project_root, nil
5f76d2d Added version info and moved Rails-specific stuff into init.rb
Joe Ferris authored
13 assert_config_default :environment_name, nil
2aed3e2 @joshuaclayton Initial implementation of logger
joshuaclayton authored
14 assert_config_default :logger, nil
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
15 assert_config_default :notifier_version, Airbrake::VERSION
16 assert_config_default :notifier_name, 'Airbrake Notifier'
da3d5c0 Migrated to new api.airbrake.io endpoint.
Jonathan Siegel authored
17 assert_config_default :notifier_url, 'https://github.com/airbrake/airbrake'
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
18 assert_config_default :secure, false
da3d5c0 Migrated to new api.airbrake.io endpoint.
Jonathan Siegel authored
19 assert_config_default :host, 'api.airbrake.io'
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
20 assert_config_default :http_open_timeout, 2
21 assert_config_default :http_read_timeout, 5
22 assert_config_default :ignore_by_filters, []
1109550 Moved ignored user agents into config
Joe Ferris authored
23 assert_config_default :ignore_user_agent, []
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
24 assert_config_default :params_filters,
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
25 Airbrake::Configuration::DEFAULT_PARAMS_FILTERS
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
26 assert_config_default :backtrace_filters,
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
27 Airbrake::Configuration::DEFAULT_BACKTRACE_FILTERS
56e2cef @shime enable filtering of env vars for rake handler
shime authored
28 assert_config_default :rake_environment_filters, []
aadaaa1 Moved ignored exceptions into configuration
Joe Ferris authored
29 assert_config_default :ignore,
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
30 Airbrake::Configuration::IGNORE_DEFAULT
6284b9f @tristandunn Add development error lookup support.
tristandunn authored
31 assert_config_default :development_lookup, true
4f106ff @jferris Fixed reporting of Rails version
jferris authored
32 assert_config_default :framework, 'Standalone'
7ae3f7e @shime add async notifications
shime authored
33 assert_config_default :async, nil
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
34 end
e8f7ae2 @qrush Cleaning up whitespace issues and splitting the test suite up
qrush authored
35
0940f2e @cris Refactor config.async to provide custom asynchronous delivery way
cris authored
36 should "set GirlFriday-callable for async=true" do
37 config = Airbrake::Configuration.new
38 config.async = true
39 assert config.async.respond_to?(:call)
40 end
41
1111f11 @cris Simplify config.async to use only notice param
cris authored
42 should "set provided-callable for async {}" do
43 config = Airbrake::Configuration.new
44 config.async {|notice| :ok}
45 assert config.async.respond_to?(:call)
46 assert_equal :ok, config.async.call
47 end
48
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
49 should "provide default values for secure connections" do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
50 config = Airbrake::Configuration.new
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
51 config.secure = true
c4959a1 Fixed port being set incorrectly for SSL
Joe Ferris authored
52 assert_equal 443, config.port
53 assert_equal 'https', config.protocol
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
54 end
e8f7ae2 @qrush Cleaning up whitespace issues and splitting the test suite up
qrush authored
55
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
56 should "provide default values for insecure connections" do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
57 config = Airbrake::Configuration.new
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
58 config.secure = false
c4959a1 Fixed port being set incorrectly for SSL
Joe Ferris authored
59 assert_equal 80, config.port
60 assert_equal 'http', config.protocol
61 end
62
63 should "not cache inferred ports" do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
64 config = Airbrake::Configuration.new
c4959a1 Fixed port being set incorrectly for SSL
Joe Ferris authored
65 config.secure = false
66 config.port
67 config.secure = true
68 assert_equal 443, config.port
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
69 end
e8f7ae2 @qrush Cleaning up whitespace issues and splitting the test suite up
qrush authored
70
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
71 should "allow values to be overwritten" do
72 assert_config_overridable :proxy_host
73 assert_config_overridable :proxy_port
74 assert_config_overridable :proxy_user
75 assert_config_overridable :proxy_pass
76 assert_config_overridable :secure
77 assert_config_overridable :host
78 assert_config_overridable :port
79 assert_config_overridable :http_open_timeout
80 assert_config_overridable :http_read_timeout
6e564a9 Merging api v2 changes
Joe Ferris authored
81 assert_config_overridable :project_root
5f76d2d Added version info and moved Rails-specific stuff into init.rb
Joe Ferris authored
82 assert_config_overridable :notifier_version
83 assert_config_overridable :notifier_name
84 assert_config_overridable :notifier_url
85 assert_config_overridable :environment_name
6284b9f @tristandunn Add development error lookup support.
tristandunn authored
86 assert_config_overridable :development_lookup
2aed3e2 @joshuaclayton Initial implementation of logger
joshuaclayton authored
87 assert_config_overridable :logger
7ae3f7e @shime add async notifications
shime authored
88 assert_config_overridable :async
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
89 end
e8f7ae2 @qrush Cleaning up whitespace issues and splitting the test suite up
qrush authored
90
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
91 should "have an api key" do
92 assert_config_overridable :api_key
93 end
e8f7ae2 @qrush Cleaning up whitespace issues and splitting the test suite up
qrush authored
94
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
95 should "act like a hash" do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
96 config = Airbrake::Configuration.new
a3ae83f Moved notice normalization into a Notice class
Joe Ferris authored
97 hash = config.to_hash
14a2c3e Fixed version numbers and other project info not appearing in notices
Joe Ferris authored
98 [:api_key, :backtrace_filters, :development_environments,
7a9c2e0 lighthouse #538 - deprecated Config#environment_filters
Jared Carroll authored
99 :environment_name, :host, :http_open_timeout,
100 :http_read_timeout, :ignore, :ignore_by_filters, :ignore_user_agent,
101 :notifier_name, :notifier_url, :notifier_version, :params_filters,
102 :project_root, :port, :protocol, :proxy_host, :proxy_pass, :proxy_port,
7ae3f7e @shime add async notifications
shime authored
103 :proxy_user, :secure, :development_lookup, :async].each do |option|
a3ae83f Moved notice normalization into a Notice class
Joe Ferris authored
104 assert_equal config[option], hash[option], "Wrong value for #{option}"
105 end
106 end
107
108 should "be mergable" do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
109 config = Airbrake::Configuration.new
a3ae83f Moved notice normalization into a Notice class
Joe Ferris authored
110 hash = config.to_hash
111 assert_equal hash.merge(:key => 'value'), config.merge(:key => 'value')
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
112 end
e8f7ae2 @qrush Cleaning up whitespace issues and splitting the test suite up
qrush authored
113
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
114 should "allow param filters to be appended" do
1109550 Moved ignored user agents into config
Joe Ferris authored
115 assert_appends_value :params_filters
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
116 end
e8f7ae2 @qrush Cleaning up whitespace issues and splitting the test suite up
qrush authored
117
56e2cef @shime enable filtering of env vars for rake handler
shime authored
118 should "allow rake environment filters to be appended" do
119 assert_appends_value :rake_environment_filters
1109550 Moved ignored user agents into config
Joe Ferris authored
120 end
121
a5163c7 @mjankowski first pass at changing JS html insertion into helper instead
mjankowski authored
122 should "warn when attempting to write js_notifier" do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
123 config = Airbrake::Configuration.new
a5163c7 @mjankowski first pass at changing JS html insertion into helper instead
mjankowski authored
124 config.
125 expects(:warn).
126 with(regexp_matches(/deprecated/i))
127 config.js_notifier = true
128 end
129
1109550 Moved ignored user agents into config
Joe Ferris authored
130 should "allow ignored user agents to be appended" do
131 assert_appends_value :ignore_user_agent
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
132 end
afc5466 Changed the sender to be swappable
Joe Ferris authored
133
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
134 should "allow backtrace filters to be appended" do
1109550 Moved ignored user agents into config
Joe Ferris authored
135 assert_appends_value(:backtrace_filters) do |config|
136 new_filter = lambda {}
137 config.filter_backtrace(&new_filter)
138 new_filter
139 end
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
140 end
e03090b Moved http properties into Sender
Joe Ferris authored
141
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
142 should "allow ignore by filters to be appended" do
1109550 Moved ignored user agents into config
Joe Ferris authored
143 assert_appends_value(:ignore_by_filters) do |config|
144 new_filter = lambda {}
145 config.ignore_by_filter(&new_filter)
146 new_filter
147 end
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
148 end
e03090b Moved http properties into Sender
Joe Ferris authored
149
aadaaa1 Moved ignored exceptions into configuration
Joe Ferris authored
150 should "allow ignored exceptions to be appended" do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
151 config = Airbrake::Configuration.new
aadaaa1 Moved ignored exceptions into configuration
Joe Ferris authored
152 original_filters = config.ignore.dup
153 new_filter = 'hello'
154 config.ignore << new_filter
155 assert_same_elements original_filters + [new_filter], config.ignore
156 end
157
1109550 Moved ignored user agents into config
Joe Ferris authored
158 should "allow ignored exceptions to be replaced" do
159 assert_replaces(:ignore, :ignore_only=)
160 end
161
162 should "allow ignored user agents to be replaced" do
163 assert_replaces(:ignore_user_agent, :ignore_user_agent_only=)
aadaaa1 Moved ignored exceptions into configuration
Joe Ferris authored
164 end
165
568a973 Moved code out of the HoptoadNotifier module and into the Notice, Con…
Joe Ferris authored
166 should "use development and test as development environments by default" do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
167 config = Airbrake::Configuration.new
4bee32a Don't send notifications from the cucumber environment
Joe Ferris authored
168 assert_same_elements %w(development test cucumber), config.development_environments
568a973 Moved code out of the HoptoadNotifier module and into the Notice, Con…
Joe Ferris authored
169 end
170
5f76d2d Added version info and moved Rails-specific stuff into init.rb
Joe Ferris authored
171 should "be public in a public environment" do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
172 config = Airbrake::Configuration.new
568a973 Moved code out of the HoptoadNotifier module and into the Notice, Con…
Joe Ferris authored
173 config.development_environments = %w(development)
5f76d2d Added version info and moved Rails-specific stuff into init.rb
Joe Ferris authored
174 config.environment_name = 'production'
568a973 Moved code out of the HoptoadNotifier module and into the Notice, Con…
Joe Ferris authored
175 assert config.public?
176 end
177
5f76d2d Added version info and moved Rails-specific stuff into init.rb
Joe Ferris authored
178 should "not be public in a development environment" do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
179 config = Airbrake::Configuration.new
568a973 Moved code out of the HoptoadNotifier module and into the Notice, Con…
Joe Ferris authored
180 config.development_environments = %w(staging)
5f76d2d Added version info and moved Rails-specific stuff into init.rb
Joe Ferris authored
181 config.environment_name = 'staging'
568a973 Moved code out of the HoptoadNotifier module and into the Notice, Con…
Joe Ferris authored
182 assert !config.public?
183 end
184
5f76d2d Added version info and moved Rails-specific stuff into init.rb
Joe Ferris authored
185 should "be public without an environment name" do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
186 config = Airbrake::Configuration.new
568a973 Moved code out of the HoptoadNotifier module and into the Notice, Con…
Joe Ferris authored
187 assert config.public?
188 end
189
2aed3e2 @joshuaclayton Initial implementation of logger
joshuaclayton authored
190 should "use the assigned logger if set" do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
191 config = Airbrake::Configuration.new
2aed3e2 @joshuaclayton Initial implementation of logger
joshuaclayton authored
192 config.logger = "CUSTOM LOGGER"
193 assert_equal "CUSTOM LOGGER", config.logger
194 end
195
5dbf4d2 Ensure a valid configuration object is always available on Airbrake.c…
Harold Giménez authored
196 should 'give a new instance if non defined' do
197 Airbrake.configuration = nil
198 assert_kind_of Airbrake::Configuration, Airbrake.configuration
199 end
200
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
201 def assert_config_default(option, default_value, config = nil)
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
202 config ||= Airbrake::Configuration.new
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
203 assert_equal default_value, config.send(option)
204 end
e03090b Moved http properties into Sender
Joe Ferris authored
205
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
206 def assert_config_overridable(option, value = 'a value')
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
207 config = Airbrake::Configuration.new
96a3db7 Moved most configuration into a Configuration class
Joe Ferris authored
208 config.send(:"#{option}=", value)
209 assert_equal value, config.send(option)
e8f7ae2 @qrush Cleaning up whitespace issues and splitting the test suite up
qrush authored
210 end
1109550 Moved ignored user agents into config
Joe Ferris authored
211
212 def assert_appends_value(option, &block)
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
213 config = Airbrake::Configuration.new
1109550 Moved ignored user agents into config
Joe Ferris authored
214 original_values = config.send(option).dup
e757649 Fixed some Ruby 1.9 issues
Joe Ferris authored
215 block ||= lambda do |config|
1109550 Moved ignored user agents into config
Joe Ferris authored
216 new_value = 'hello'
217 config.send(option) << new_value
218 new_value
219 end
220 new_value = block.call(config)
221 assert_same_elements original_values + [new_value], config.send(option)
222 end
223
224 def assert_replaces(option, setter)
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
225 config = Airbrake::Configuration.new
1109550 Moved ignored user agents into config
Joe Ferris authored
226 new_value = 'hello'
227 config.send(setter, [new_value])
228 assert_equal [new_value], config.send(option)
229 config.send(setter, new_value)
230 assert_equal [new_value], config.send(option)
231 end
232
e8f7ae2 @qrush Cleaning up whitespace issues and splitting the test suite up
qrush authored
233 end
Something went wrong with that request. Please try again.