party_fouls 1.5.6 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +4 -19
  3. data/Rakefile +2 -0
  4. data/lib/generators/party_foul/install_generator.rb +2 -0
  5. data/lib/generators/party_foul/templates/party_foul.rb +2 -0
  6. data/lib/party_foul.rb +2 -0
  7. data/lib/party_foul/exception_handler.rb +2 -0
  8. data/lib/party_foul/issue_renderers.rb +2 -0
  9. data/lib/party_foul/issue_renderers/base.rb +5 -5
  10. data/lib/party_foul/issue_renderers/rack.rb +2 -0
  11. data/lib/party_foul/issue_renderers/rackless.rb +2 -0
  12. data/lib/party_foul/issue_renderers/rails.rb +2 -0
  13. data/lib/party_foul/middleware.rb +2 -0
  14. data/lib/party_foul/processors.rb +2 -0
  15. data/lib/party_foul/processors/base.rb +2 -0
  16. data/lib/party_foul/processors/delayed_job.rb +2 -0
  17. data/lib/party_foul/processors/resque.rb +2 -0
  18. data/lib/party_foul/processors/sidekiq.rb +2 -0
  19. data/lib/party_foul/processors/sync.rb +2 -0
  20. data/lib/party_foul/rackless_exception_handler.rb +2 -0
  21. data/lib/party_foul/version.rb +3 -1
  22. metadata +13 -33
  23. data/test/generator_test.rb +0 -26
  24. data/test/party_foul/configure_test.rb +0 -37
  25. data/test/party_foul/exception_handler_test.rb +0 -205
  26. data/test/party_foul/issue_renderers/base_test.rb +0 -210
  27. data/test/party_foul/issue_renderers/rack_test.rb +0 -80
  28. data/test/party_foul/issue_renderers/rackless_test.rb +0 -29
  29. data/test/party_foul/issue_renderers/rails_test.rb +0 -83
  30. data/test/party_foul/middleware_test.rb +0 -48
  31. data/test/party_foul/rackless_exception_handler_test.rb +0 -33
  32. data/test/test_helper.rb +0 -42
  33. data/test/tmp/config/initializers/party_foul.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 24bb7632ea8be8c278cd4583225f4f7d5dfbf4fb
4
- data.tar.gz: ad2655ec1e1f1b26d46355941b2a77f0ab7b2a19
2
+ SHA256:
3
+ metadata.gz: 021176d3d1af86241e608570bf3333d36c3e08c3c0bfd8c9781bf34061271791
4
+ data.tar.gz: 30fcfd0e6840fc862cc16b919a0474ffc6124ec311c844fd90ecb7abd88d2ae8
5
5
  SHA512:
6
- metadata.gz: 0eb1eaea0c9d6a0beed7ae74c16cee3e485daeb01cb41f9fb11f0b66069d641b95d59bd9b5746db2eeb0392bc323459a2210e26aa9ed08849b50c7180e0a5670
7
- data.tar.gz: da6149b6f020abd7f5f9e3f1f5d2a63a531b90b933b40932ce62bba6f87e0841045b069d79b5cca5a93206e22b766281dc6a1bd1fb0624003932866e5a7ca33a
6
+ metadata.gz: 639dab7820cd7b7570fdff7caca5fd8cad33012cde7b7623e127b64b9f42e6fe0dd934e0140b92f09b9df48f9971e5e1418bd3dfe188cc859649fd2adf66545e
7
+ data.tar.gz: 0d83042df6f96da24b01e23e363b8aa61e93d07b94841f2e50a3a6ce0a4778c8360c5a23d87c23e26cab1d00e5d2c34534e5ce5a797df4e0d19e74de7dab7fe9
data/README.md CHANGED
@@ -4,10 +4,9 @@ Rails exceptions automatically opened as issues on GitHub
4
4
 
5
5
  # This is a fork, released as the `party_fouls` gem
6
6
 
7
- ## Looking for help? ##
8
-
9
- If it is a bug [please open an issue on
10
- GitHub](https://github.com/dockyard/party_foul/issues).
7
+ ```ruby
8
+ gem 'party_fouls', require: 'party_foul'
9
+ ```
11
10
 
12
11
  ## About ##
13
12
 
@@ -37,12 +36,6 @@ for the installation below. If you use your own account you will
37
36
  not receive emails when issues are created, updated, reopened, etc...
38
37
  because all of the work is done as your account.
39
38
 
40
- In your Gemfile add the following:
41
-
42
- ```ruby
43
- gem 'party_foul'
44
- ```
45
-
46
39
  ### Rails ###
47
40
  If you are using Rails you can run the install generator.
48
41
 
@@ -242,23 +235,15 @@ end
242
235
 
243
236
  This will pass the worker class name and queue as well as all worker-related parameters off to PartyFoul before passing on the exception.
244
237
 
245
- ## Authors ##
238
+ ## Authors (original) ##
246
239
 
247
240
  * [Brian Cardarella](http://twitter.com/bcardarella)
248
241
  * [Dan McClain](http://twitter.com/_danmcclain)
249
242
 
250
- [We are very thankful for the many contributors](https://github.com/dockyard/party_foul/graphs/contributors)
251
-
252
243
  ## Versioning ##
253
244
 
254
245
  This gem follows [Semantic Versioning](http://semver.org)
255
246
 
256
- ## Want to help? ##
257
-
258
- Please do! We are always looking to improve this gem. Please see our
259
- [Contribution Guidelines](https://github.com/dockyard/party_foul/blob/master/CONTRIBUTING.md)
260
- on how to properly submit issues and pull requests.
261
-
262
247
  ## Legal ##
263
248
 
264
249
  [DockYard](http://dockyard.com), LLC © 2013
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env rake
2
+ # frozen_string_literal: true
3
+
2
4
  begin
3
5
  require 'bundler/setup'
4
6
  rescue LoadError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators'
2
4
  require 'net/http'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  PartyFoul.configure do |config|
2
4
  # The collection of exceptions PartyFoul should not be allowed to handle
3
5
  # The constants here *must* be represented as strings
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'octokit'
2
4
 
3
5
  module PartyFoul
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PartyFoul::ExceptionHandler
2
4
  attr_accessor :rendered_issue
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PartyFoul::IssueRenderers; end
2
4
  require 'party_foul/issue_renderers/base'
3
5
  require 'party_foul/issue_renderers/rack'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cgi'
2
4
 
3
5
  class PartyFoul::IssueRenderers::Base
@@ -15,13 +17,11 @@ class PartyFoul::IssueRenderers::Base
15
17
  #
16
18
  # @return [String]
17
19
  def title
18
- _title = if PartyFoul.title_prefix
20
+ if PartyFoul.title_prefix
19
21
  "[#{PartyFoul.title_prefix}] #{masked_title}"
20
22
  else
21
23
  masked_title
22
- end
23
-
24
- _title[0..255]
24
+ end[0..255]
25
25
  end
26
26
 
27
27
  # Renders the issue body
@@ -134,7 +134,7 @@ BODY
134
134
  else
135
135
  value = CGI.escapeHTML(value.to_s)
136
136
  end
137
- rows << "<tr><th>#{key}</th><td>#{value}</td></tr>"
137
+ rows += "<tr><th>#{key}</th><td>#{value}</td></tr>"
138
138
  end
139
139
  end
140
140
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PartyFoul::IssueRenderers::Rack < PartyFoul::IssueRenderers::Base
2
4
 
3
5
  def request
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'party_foul/issue_renderers/base'
2
4
 
3
5
  class PartyFoul::IssueRenderers::Rackless < PartyFoul::IssueRenderers::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PartyFoul::IssueRenderers::Rails < PartyFoul::IssueRenderers::Rack
2
4
  # Rails params hash. Filtered parms are respected.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PartyFoul
2
4
  class Middleware
3
5
  def initialize(app)
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PartyFoul::Processors; end
2
4
  require 'party_foul/processors/sync'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PartyFoul::Processors::Base
2
4
  # Passes the exception and rack env data to the ExceptionHandler and
3
5
  # runs everything synchronously. This base class method must be
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'party_foul/processors/base'
2
4
 
3
5
  class PartyFoul::Processors::DelayedJob < PartyFoul::Processors::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'party_foul/processors/base'
2
4
 
3
5
  class PartyFoul::Processors::Resque < PartyFoul::Processors::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'party_foul/processors/base'
2
4
 
3
5
  class PartyFoul::Processors::Sidekiq < PartyFoul::Processors::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'party_foul/processors/base'
2
4
 
3
5
  class PartyFoul::Processors::Sync < PartyFoul::Processors::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PartyFoul::RacklessExceptionHandler < PartyFoul::ExceptionHandler
2
4
  # This handler will pass the exception and working environment from Rack off to a processor.
3
5
  # The default PartyFoul processor will work synchronously. Processor adapters can be written
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PartyFoul
2
- VERSION = '1.5.6'.freeze
4
+ VERSION = '1.6.0'
3
5
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: party_fouls
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.6
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cardarella
8
8
  - Dan McClain
9
+ - Tee Parham
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2017-02-24 00:00:00.000000000 Z
13
+ date: 2018-02-23 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: octokit
@@ -31,42 +32,42 @@ dependencies:
31
32
  requirements:
32
33
  - - "~>"
33
34
  - !ruby/object:Gem::Version
34
- version: '4.0'
35
+ version: '5.0'
35
36
  type: :development
36
37
  prerelease: false
37
38
  version_requirements: !ruby/object:Gem::Requirement
38
39
  requirements:
39
40
  - - "~>"
40
41
  - !ruby/object:Gem::Version
41
- version: '4.0'
42
+ version: '5.0'
42
43
  - !ruby/object:Gem::Dependency
43
44
  name: activesupport
44
45
  requirement: !ruby/object:Gem::Requirement
45
46
  requirements:
46
47
  - - "~>"
47
48
  - !ruby/object:Gem::Version
48
- version: '4.0'
49
+ version: '5.0'
49
50
  type: :development
50
51
  prerelease: false
51
52
  version_requirements: !ruby/object:Gem::Requirement
52
53
  requirements:
53
54
  - - "~>"
54
55
  - !ruby/object:Gem::Version
55
- version: '4.0'
56
+ version: '5.0'
56
57
  - !ruby/object:Gem::Dependency
57
58
  name: railties
58
59
  requirement: !ruby/object:Gem::Requirement
59
60
  requirements:
60
61
  - - "~>"
61
62
  - !ruby/object:Gem::Version
62
- version: '4.0'
63
+ version: '5.0'
63
64
  type: :development
64
65
  prerelease: false
65
66
  version_requirements: !ruby/object:Gem::Requirement
66
67
  requirements:
67
68
  - - "~>"
68
69
  - !ruby/object:Gem::Version
69
- version: '4.0'
70
+ version: '5.0'
70
71
  - !ruby/object:Gem::Dependency
71
72
  name: minitest
72
73
  requirement: !ruby/object:Gem::Requirement
@@ -141,6 +142,7 @@ description: Auto-submit Rails exceptions as new issues on GitHub
141
142
  email:
142
143
  - bcardarella@gmail.com
143
144
  - rubygems@danmcclain.net
145
+ - parhameter@gmail.com
144
146
  executables: []
145
147
  extensions: []
146
148
  extra_rdoc_files: []
@@ -165,17 +167,6 @@ files:
165
167
  - lib/party_foul/processors/sync.rb
166
168
  - lib/party_foul/rackless_exception_handler.rb
167
169
  - lib/party_foul/version.rb
168
- - test/generator_test.rb
169
- - test/party_foul/configure_test.rb
170
- - test/party_foul/exception_handler_test.rb
171
- - test/party_foul/issue_renderers/base_test.rb
172
- - test/party_foul/issue_renderers/rack_test.rb
173
- - test/party_foul/issue_renderers/rackless_test.rb
174
- - test/party_foul/issue_renderers/rails_test.rb
175
- - test/party_foul/middleware_test.rb
176
- - test/party_foul/rackless_exception_handler_test.rb
177
- - test/test_helper.rb
178
- - test/tmp/config/initializers/party_foul.rb
179
170
  homepage: https://github.com/neighborland/party_foul
180
171
  licenses:
181
172
  - MIT
@@ -188,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
179
  requirements:
189
180
  - - ">="
190
181
  - !ruby/object:Gem::Version
191
- version: 2.1.0
182
+ version: 2.3.3
192
183
  required_rubygems_version: !ruby/object:Gem::Requirement
193
184
  requirements:
194
185
  - - ">="
@@ -196,19 +187,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
187
  version: '0'
197
188
  requirements: []
198
189
  rubyforge_project:
199
- rubygems_version: 2.6.10
190
+ rubygems_version: 2.7.6
200
191
  signing_key:
201
192
  specification_version: 4
202
193
  summary: Auto-submit Rails exceptions as new issues on GitHub
203
- test_files:
204
- - test/generator_test.rb
205
- - test/party_foul/configure_test.rb
206
- - test/party_foul/exception_handler_test.rb
207
- - test/party_foul/issue_renderers/base_test.rb
208
- - test/party_foul/issue_renderers/rack_test.rb
209
- - test/party_foul/issue_renderers/rackless_test.rb
210
- - test/party_foul/issue_renderers/rails_test.rb
211
- - test/party_foul/middleware_test.rb
212
- - test/party_foul/rackless_exception_handler_test.rb
213
- - test/test_helper.rb
214
- - test/tmp/config/initializers/party_foul.rb
194
+ test_files: []
@@ -1,26 +0,0 @@
1
- require 'test_helper'
2
- require 'rails/generators/test_case'
3
- require 'generators/party_foul/install_generator'
4
-
5
- class PartyFoul::GeneratorTest < Rails::Generators::TestCase
6
- destination File.expand_path('../tmp', __FILE__)
7
- tests PartyFoul::InstallGenerator
8
-
9
- test 'it copies the initializer' do
10
- owner = 'test_owner'
11
- repo = 'test_repo'
12
- octokit = mock('Octokit::Client')
13
- octokit.expects(:create_authorization).with(scopes: ['repo'], note: 'PartyFoul test_owner/test_repo', note_url: 'http://example.com/test_owner/test_repo').returns(sawyer_resource({token: 'test_token'}))
14
- Octokit::Client.stubs(:new).with(:login => 'test_login', :password => 'test_password', :api_endpoint => 'http://api.example.com').returns(octokit)
15
- ::Readline.stubs(:readline).returns('test_login').then.returns('test_password').then.returns(owner).then.returns(repo).then.returns('http://api.example.com').then.returns('http://example.com').then.returns('')
16
- run_generator
17
-
18
- assert_file 'config/initializers/party_foul.rb' do |initializer|
19
- assert_match(/config\.api_endpoint\s+=\s'http:\/\/api\.example\.com'/, initializer)
20
- assert_match(/config\.web_url\s+=\s'http:\/\/example\.com'/, initializer)
21
- assert_match(/config\.owner\s+=\s'test_owner'/, initializer)
22
- assert_match(/config\.repo\s+=\s'test_repo'/, initializer)
23
- assert_match(/config\.oauth_token\s+=\s'test_token'/, initializer)
24
- end
25
- end
26
- end
@@ -1,37 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe 'Party Foul Confg' do
4
-
5
- after do
6
- clean_up_party
7
- end
8
-
9
- it 'sets the proper config variables' do
10
- PartyFoul.configure do |config|
11
- config.blacklisted_exceptions = ['StandardError']
12
- config.oauth_token = 'test_token'
13
- config.web_url = 'http://example.com'
14
- config.api_endpoint = 'http://api.example.com'
15
- config.owner = 'test_owner'
16
- config.repo = 'test_repo'
17
- config.branch = 'master'
18
- config.comment_limit = 10
19
- end
20
-
21
- PartyFoul.blacklisted_exceptions.must_equal ['StandardError']
22
- PartyFoul.github.must_be_instance_of Octokit::Client
23
- PartyFoul.github.access_token.must_equal 'test_token'
24
- PartyFoul.github.api_endpoint.must_equal 'http://api.example.com/'
25
- PartyFoul.owner.must_equal 'test_owner'
26
- PartyFoul.repo.must_equal 'test_repo'
27
- PartyFoul.repo_path.must_equal 'test_owner/test_repo'
28
- PartyFoul.repo_url.must_equal 'http://example.com/test_owner/test_repo'
29
- PartyFoul.branch.must_equal 'master'
30
- PartyFoul.comment_limit.must_equal 10
31
- end
32
-
33
- it 'has default values' do
34
- PartyFoul.web_url.must_equal 'https://github.com'
35
- PartyFoul.branch.must_equal 'master'
36
- end
37
- end
@@ -1,205 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe 'Party Foul Exception Handler' do
4
- before do
5
- PartyFoul.configure do |config|
6
- config.oauth_token = 'abcdefg1234567890'
7
- config.owner = 'test_owner'
8
- config.repo = 'test_repo'
9
- end
10
-
11
- PartyFoul.stubs(:branch).returns('deploy')
12
- PartyFoul::IssueRenderers::Rails.any_instance.stubs(:title).returns('Test Title')
13
- PartyFoul::IssueRenderers::Rails.any_instance.stubs(:fingerprint).returns('test_fingerprint')
14
- end
15
-
16
- context 'when error is new' do
17
- it 'will open a new error on GitHub' do
18
- PartyFoul::IssueRenderers::Rails.any_instance.stubs(:body).returns('Test Body')
19
- PartyFoul::IssueRenderers::Rails.any_instance.stubs(:comment).returns('Test Comment')
20
- PartyFoul.github.expects(:search_issues).with('test_fingerprint repo:test_owner/test_repo state:open').returns(no_search_results)
21
- PartyFoul.github.expects(:search_issues).with('test_fingerprint repo:test_owner/test_repo state:closed').returns(no_search_results)
22
- PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', labels: ['bug']).returns( {number: 1} )
23
- PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns( sawyer_resource({object: {sha: 'abcdefg1234567890'}}) )
24
- PartyFoul.github.expects(:add_comment).with('test_owner/test_repo', 1, 'Test Comment')
25
- PartyFoul::ExceptionHandler.new(nil, {}).run
26
- end
27
-
28
- context 'when additional labels are configured' do
29
- before do
30
- PartyFoul.configure do |config|
31
- config.additional_labels = ['custom', 'label']
32
- end
33
- end
34
- after do
35
- clean_up_party
36
- end
37
- it 'will open a new error on GitHub with the additional labels' do
38
- PartyFoul::IssueRenderers::Rails.any_instance.stubs(:body).returns('Test Body')
39
- PartyFoul::IssueRenderers::Rails.any_instance.stubs(:comment).returns('Test Comment')
40
- PartyFoul.github.expects(:search_issues).with('test_fingerprint repo:test_owner/test_repo state:open').returns(no_search_results)
41
- PartyFoul.github.expects(:search_issues).with('test_fingerprint repo:test_owner/test_repo state:closed').returns(no_search_results)
42
- PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug', 'custom', 'label']).returns( { number: 1 } )
43
- PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns( sawyer_resource({object: {sha: 'abcdefg1234567890'}}) )
44
- PartyFoul.github.expects(:add_comment).with('test_owner/test_repo', 1, 'Test Comment')
45
- PartyFoul::ExceptionHandler.new(nil, {}).run
46
- end
47
- end
48
-
49
- context 'when a proc for additional labels are configured' do
50
- before do
51
- PartyFoul.configure do |config|
52
- config.additional_labels = Proc.new do |exception, env|
53
- if env[:http_host] =~ /beta\./
54
- ['beta']
55
- elsif exception.message =~ /Database/
56
- ['database_error']
57
- end
58
- end
59
- end
60
- PartyFoul::IssueRenderers::Rails.any_instance.stubs(:body).returns('Test Body')
61
- PartyFoul::IssueRenderers::Rails.any_instance.stubs(:comment).returns('Test Comment')
62
- PartyFoul.github.expects(:search_issues).with('test_fingerprint repo:test_owner/test_repo state:open').returns(no_search_results)
63
- PartyFoul.github.expects(:search_issues).with('test_fingerprint repo:test_owner/test_repo state:closed').returns(no_search_results)
64
- PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns( sawyer_resource({object: {sha: 'abcdefg1234567890'}}) )
65
- PartyFoul.github.expects(:add_comment).with('test_owner/test_repo', 1, 'Test Comment')
66
- end
67
- after do
68
- clean_up_party
69
- end
70
-
71
- it 'will open a new error on GitHub with the default labels if no additional labels are returned from the proc' do
72
- PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug']).returns({ number: 1 })
73
- PartyFoul::ExceptionHandler.new(stub(:message => ''), {}).run
74
- end
75
-
76
- it 'will open a new error on GitHub with the additional labels based on the exception message' do
77
- PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug', 'database_error']).returns({ number: 1 })
78
- PartyFoul::ExceptionHandler.new(stub(:message => 'Database'), {}).run
79
- end
80
-
81
- it 'will open a new error on GitHub with the additional labels based on the env' do
82
- PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug', 'beta']).returns({ number: 1 })
83
- PartyFoul::ExceptionHandler.new(stub(:message => ''), {:http_host => 'beta.example.com'}).run
84
- end
85
- end
86
- end
87
-
88
- context 'when error is not new' do
89
- before do
90
- PartyFoul::IssueRenderers::Rails.any_instance.stubs(:update_body).returns('New Body')
91
- PartyFoul::IssueRenderers::Rails.any_instance.stubs(:comment).returns('Test Comment')
92
- end
93
-
94
- context 'and open' do
95
- before do
96
- PartyFoul.github.expects(:search_issues).with('test_fingerprint repo:test_owner/test_repo state:open').returns(
97
- sawyer_resource({total_count: 1, incomplete_results: false, items:[{title: 'Test Title', body: 'Test Body', state: 'open', number: 1}]}) )
98
- PartyFoul.github.expects(:update_issue).with('test_owner/test_repo', 1, 'Test Title', 'New Body', state: 'open')
99
- PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns(
100
- sawyer_resource({object: {sha: 'abcdefg1234567890'}}) )
101
- end
102
-
103
- it 'will update the issue' do
104
- PartyFoul.github.expects(:add_comment).with('test_owner/test_repo', 1, 'Test Comment')
105
- PartyFoul::ExceptionHandler.new(nil, {}).run
106
- end
107
-
108
- it "doesn't post a comment if the limit has been met" do
109
- PartyFoul.comment_limit = 10
110
- PartyFoul::ExceptionHandler.any_instance.expects(:occurrence_count).returns(10)
111
- PartyFoul.github.expects(:add_comment).never
112
- PartyFoul::ExceptionHandler.new(nil, {}).run
113
- end
114
- end
115
-
116
- context 'and closed' do
117
- it 'will update the count on the body and re-open the issue' do
118
- PartyFoul.github.expects(:search_issues).with('test_fingerprint repo:test_owner/test_repo state:open').returns(no_search_results)
119
- PartyFoul.github.expects(:search_issues).with('test_fingerprint repo:test_owner/test_repo state:closed').returns(
120
- sawyer_resource({total_count: 1, incomplete_results: false, items:[{title: 'Test Title', body: 'Test Body', state: 'closed', number: 1, labels: [{url: 'https://api.github.com/repos/test_owner/test_repo/labels/staging', name: 'staging', color: 'f29513'}]}]}) )
121
- PartyFoul.github.expects(:update_issue).with('test_owner/test_repo', 1, 'Test Title', 'New Body', state: 'open', labels: ['bug', 'regression', 'staging'])
122
- PartyFoul.github.expects(:add_comment).with('test_owner/test_repo', 1, 'Test Comment')
123
- PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns(sawyer_resource({object: {sha: 'abcdefg1234567890'}}))
124
- PartyFoul::ExceptionHandler.new(nil, {}).run
125
- end
126
- end
127
- end
128
-
129
- context 'when issue is marked as "wontfix"' do
130
- it 'does nothing' do
131
- PartyFoul::IssueRenderers::Rails.any_instance.stubs(:body).returns('Test Body')
132
- PartyFoul.github.expects(:search_issues).with('test_fingerprint repo:test_owner/test_repo state:open').returns(no_search_results)
133
- PartyFoul.github.expects(:search_issues).with('test_fingerprint repo:test_owner/test_repo state:closed').returns(
134
- sawyer_resource({total_count: 1, incomplete_results: false, items:[{title: 'Test Title', body: 'Test Body', state: 'closed', number: 1, labels: [{url: 'https://api.github.com/repos/test_owner/test_repo/labels/wontfix', name: 'wontfix', color: 'f29513'}]}]}) )
135
- PartyFoul.github.expects(:create_issue).never
136
- PartyFoul.github.expects(:update_issue).never
137
- PartyFoul.github.expects(:add_comment).never
138
- PartyFoul.github.expects(:references).never
139
- PartyFoul::ExceptionHandler.new(nil, {}).run
140
- end
141
- end
142
-
143
- describe '#occurrence_count' do
144
- before do
145
- @handler = PartyFoul::ExceptionHandler.new(nil, {})
146
- end
147
-
148
- it "returns the count" do
149
- @handler.send(:occurrence_count, "<th>Count</th><td>1</td>").must_equal 1
150
- end
151
-
152
- it "returns 0 if no count is found" do
153
- @handler.send(:occurrence_count, "Unexpected Body").must_equal 0
154
- end
155
- end
156
-
157
- describe '#comment_limit_met?' do
158
- before do
159
- @handler = PartyFoul::ExceptionHandler.new(nil, {})
160
- end
161
-
162
- context "with no limit" do
163
- it "returns false when there is no limit" do
164
- PartyFoul.configure do |config|
165
- config.comment_limit = nil
166
- end
167
- @handler.send(:comment_limit_met?, "").must_equal false
168
- end
169
- end
170
-
171
- context "with a limit" do
172
- before do
173
- PartyFoul.configure do |config|
174
- config.comment_limit = 10
175
- end
176
- end
177
-
178
- it "returns false when there is a limit that has not been hit" do
179
- @handler.stubs(:occurrence_count).returns(1)
180
- @handler.send(:comment_limit_met?, "").must_equal false
181
- end
182
-
183
- it "returns true if the limit has been hit" do
184
- @handler.stubs(:occurrence_count).returns(10)
185
- @handler.send(:comment_limit_met?, "").must_equal true
186
- end
187
- end
188
- end
189
-
190
- describe '.clean_env' do
191
- context 'when env contains file reference' do
192
- before do
193
- @env = {
194
- 'action_dispatch.request.parameters' => {
195
- :@tempfile => File.open(__FILE__)
196
- }
197
- }
198
- end
199
-
200
- it "marshal dump shouldn't reject values when they contain File" do
201
- PartyFoul::ExceptionHandler.send(:clean_env, @env)['action_dispatch.request.parameters'].must_be_instance_of Hash
202
- end
203
- end
204
- end
205
- end
@@ -1,210 +0,0 @@
1
- require 'test_helper'
2
- require 'active_support/core_ext/object/blank'
3
- require 'action_dispatch/http/parameter_filter'
4
-
5
- describe 'Party Foul Issue Renderer Base' do
6
- before do
7
- Time.stubs(:now).returns(Time.new(1970, 1, 1, 0, 0, 0, '-05:00'))
8
- end
9
-
10
- after do
11
- clean_up_party
12
- end
13
-
14
- describe '#body' do
15
- describe 'updating issue body' do
16
- before do
17
- @rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
18
- @rendered_issue.stubs(:exception).returns('Test Exception')
19
- @rendered_issue.stubs(:fingerprint).returns('abcdefg1234567890')
20
- @rendered_issue.stubs(:stack_trace)
21
- end
22
-
23
- it 'updates count and timestamp' do
24
- body = <<-BODY.gsub(/\n/, '')
25
- <table>
26
- <tr><th>Exception</th><td>Test Exception</td></tr>
27
- <tr><th>Last Occurrence</th><td>January 01, 1970 00:00:00 -0500</td></tr>
28
- <tr><th>Count</th><td>1</td></tr>
29
- </table>
30
-
31
- ## Stack Trace
32
- <pre></pre>
33
- Fingerprint: `abcdefg1234567890`
34
- BODY
35
-
36
- Time.stubs(:now).returns(Time.new(1985, 10, 25, 1, 22, 0, '-05:00'))
37
-
38
- expected_body = <<-BODY.gsub(/\n/, '')
39
- <table>
40
- <tr><th>Exception</th><td>Test Exception</td></tr>
41
- <tr><th>Last Occurrence</th><td>October 25, 1985 01:22:00 -0500</td></tr>
42
- <tr><th>Count</th><td>2</td></tr>
43
- </table>
44
-
45
- ## Stack Trace
46
- <pre></pre>
47
- Fingerprint: `abcdefg1234567890`
48
- BODY
49
-
50
- @rendered_issue.update_body(body).must_equal expected_body
51
- end
52
- end
53
-
54
- describe 'empty body' do
55
- before do
56
- @rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
57
- @rendered_issue.stubs(:exception).returns('Test Exception')
58
- @rendered_issue.stubs(:fingerprint).returns('abcdefg1234567890')
59
- @rendered_issue.stubs(:stack_trace)
60
- end
61
-
62
- it 'resets body' do
63
- expected_body = <<-BODY
64
- <table><tr><th>Exception</th><td>Test Exception</td></tr><tr><th>Last Occurrence</th><td>January 01, 1970 00:00:00 -0500</td></tr><tr><th>Count</th><td>1</td></tr></table>
65
-
66
- ## Stack Trace
67
- <pre></pre>
68
- Fingerprint: `abcdefg1234567890`
69
- BODY
70
- @rendered_issue.update_body(nil).must_equal expected_body
71
- end
72
- end
73
- end
74
-
75
- describe '#build_table_from_hash' do
76
- it 'builds an HTML table from a hash' do
77
- rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
78
- hash = { 'Value 1' => 'abc', 'Value 2' => { 'Value A' => 123, 'Value B' => 456 } }
79
- expected = '<table><tr><th>Value 1</th><td>abc</td></tr><tr><th>Value 2</th><td><table><tr><th>Value A</th><td>123</td></tr><tr><th>Value B</th><td>456</td></tr></table></td></tr></table>'
80
- rendered_issue.build_table_from_hash(hash).must_equal expected
81
- end
82
-
83
- it 'escapes HTML entities' do
84
- rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
85
- hash = { 'Value 1' => 'Error in #<Foo>' }
86
- expected = '<table><tr><th>Value 1</th><td>Error in #&lt;Foo&gt;</td></tr></table>'
87
- rendered_issue.build_table_from_hash(hash).must_equal expected
88
- end
89
- end
90
-
91
- describe '#fingerprint' do
92
- it 'SHA1s the title' do
93
- rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
94
- rendered_issue.stubs(:title).returns('abcdefg1234567890')
95
- rendered_issue.fingerprint.must_equal Digest::SHA1.hexdigest(rendered_issue.title)
96
- end
97
- end
98
-
99
- describe '#occurred_at' do
100
- it 'memoizes the time' do
101
- rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
102
- expected = rendered_issue.occurred_at
103
- Time.stubs(:now).returns(Time.new(1970, 1, 1, 0, 0, 1, '-05:00'))
104
- rendered_issue.occurred_at.must_equal expected
105
- end
106
- end
107
-
108
- describe '#title' do
109
- context 'when no title prefix is configured' do
110
- before do
111
- PartyFoul.configure do |config|
112
- config.title_prefix = nil
113
- end
114
- end
115
-
116
- it 'masks the object ids in the raw_title' do
117
- rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
118
- rendered_issue.stubs(:raw_title).returns('Error for #<ClassName:0xabcdefg1234567>')
119
- rendered_issue.title.must_equal 'Error for #<ClassName:0xXXXXXX>'
120
- end
121
-
122
- it 'masks the extended object ids in the raw_title' do
123
- rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
124
- rendered_issue.stubs(:raw_title).returns('Error for #<#<ClassName:0x007fbddbdcd340>:0x007fbddf6be0a0>')
125
- rendered_issue.title.must_equal 'Error for #<#<ClassName:0xXXXXXX>:0xXXXXXX>'
126
- end
127
- end
128
-
129
- context 'when a custom title prefix is configured' do
130
- before do
131
- PartyFoul.configure do |config|
132
- config.title_prefix = 'PRODUCTION'
133
- end
134
- end
135
-
136
- it 'adds a custom prefix' do
137
- rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
138
- rendered_issue.stubs(:raw_title).returns('Error')
139
- rendered_issue.title.must_equal '[PRODUCTION] Error'
140
- end
141
-
142
- it 'generated unique fingerprints' do
143
- rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
144
- rendered_issue.stubs(:raw_title).returns('Error')
145
- fingerprint = rendered_issue.fingerprint
146
-
147
- PartyFoul.configure do |config|
148
- config.title_prefix = 'STAGING'
149
- end
150
-
151
- fingerprint.wont_equal rendered_issue.fingerprint
152
- end
153
- end
154
-
155
- context 'title length limit' do
156
- before do
157
- PartyFoul.configure do |config|
158
- config.title_prefix = 'PRODUCTION'
159
- end
160
- end
161
-
162
- it 'at most 256 chars' do
163
- rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
164
- rendered_issue.stubs(:raw_title).returns('F'*300)
165
- rendered_issue.title.size.must_equal 256
166
- end
167
- end
168
- end
169
-
170
- describe '#stack_trace' do
171
- # it 'returns the stack trace' do
172
- # exception = mock do
173
- # stubs backtrace: ['/path/to/gems/gem-name/lib/some/file.rb:123 in `method`']
174
- # end
175
- # rendered_issue = PartyFoul::IssueRenderers::Base.new(exception, nil)
176
- # rendered_issue.stack_trace.must_equal exception.backtrace.first
177
- # end
178
-
179
- it 'formats the stack trace with shortened bundle paths' do
180
- exception = mock do
181
- stubs backtrace: ["#{Bundler.bundle_path}/some_gem/lib/some/file.rb:123 in `method`"]
182
- end
183
-
184
- rendered_issue = PartyFoul::IssueRenderers::Base.new(exception, nil)
185
- rendered_issue.stack_trace.must_equal '[bundle].../some_gem/lib/some/file.rb:123 in `method`'
186
- end
187
-
188
- it 'formats the stack trace with link to shortened application path' do
189
- clean_up_party
190
- exception = mock do
191
- stubs backtrace: ['/path/to/app/lib/some/file.rb:123 in `method`']
192
- end
193
- rendered_issue = PartyFoul::IssueRenderers::Base.new(exception, nil)
194
- rendered_issue.stubs app_root: '/path/to/app'
195
- rendered_issue.stack_trace.must_match "<a href='https://github.com///blob//lib/some/file.rb#L123'>[app].../lib/some/file.rb:123 in `method`</a>"
196
- end
197
-
198
- it 'does not link to bundled resources on Heroku' do
199
- Bundler.stub(:bundle_path, '/app/vendor/bundle/ruby/2.0.0') do
200
- exception = mock do
201
- stubs backtrace: ["#{Bundler.bundle_path}/some_gem/lib/some/file.rb:123 in `method`"]
202
- end
203
-
204
- rendered_issue = PartyFoul::IssueRenderers::Base.new(exception, nil)
205
- rendered_issue.stubs app_root: '/app'
206
- rendered_issue.stack_trace.must_equal '[bundle].../some_gem/lib/some/file.rb:123 in `method`'
207
- end
208
- end
209
- end
210
- end
@@ -1,80 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe 'Rack Issue Renderer' do
4
- describe '#params' do
5
- before do
6
- @issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil, ::Rack::MockRequest.env_for("/?status=ok"))
7
- end
8
-
9
- it 'returns the value of the query param' do
10
- @issue_renderer.params['status'].must_equal 'ok'
11
- end
12
- end
13
-
14
- describe '#raw_title' do
15
- before do
16
- @exception = Exception.new('message')
17
- end
18
-
19
- it 'constructs the title with the class and instance method' do
20
- @issue_renderer = PartyFoul::IssueRenderers::Rack.new(@exception, {})
21
- @issue_renderer.send(:raw_title).must_equal %{(Exception) "message"}
22
- end
23
- end
24
-
25
- describe '#request' do
26
- it 'builds a rack request' do
27
- issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil, {})
28
- assert issue_renderer.request.is_a?(::Rack::Request)
29
- end
30
- end
31
-
32
- describe '#ip_address_geolocator' do
33
- # we are delegating to rack, see
34
- # https://github.com/rack/rack/blob/master/test/spec_request.rb
35
-
36
- it 'returns the link to geolocation IP address when REMOTE_ADDR is set' do
37
- issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil, { 'REMOTE_ADDR' => '1.2.3.4' })
38
- ip_addr = "<a href='http://ipinfo.io/1.2.3.4'>1.2.3.4</a>"
39
- issue_renderer.ip_address_locator.must_equal ip_addr
40
- end
41
-
42
- it 'return the link to geolocation IP address when HTTP_X_FORWARDED_FOR is set' do
43
- issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil, { 'HTTP_X_FORWARDED_FOR' => '10.0.0.1, 10.0.0.1, 3.4.5.6' })
44
- ip_addr = "<a href='http://ipinfo.io/3.4.5.6'>3.4.5.6</a>"
45
- issue_renderer.ip_address_locator.must_equal ip_addr
46
- end
47
- end
48
-
49
- describe '#url' do
50
- it 'returns the method and uri' do
51
- issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil, { 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/something' })
52
- issue_renderer.url.must_equal '[GET] /something'
53
- end
54
- end
55
-
56
- describe '#session' do
57
- it 'returns the session' do
58
- issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil, { 'rack.session' => 'abc:123' })
59
- issue_renderer.session.must_equal 'abc:123'
60
- end
61
- end
62
-
63
- describe '#http_headers' do
64
- it 'returns http headers' do
65
- issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil,
66
- {
67
- 'HTTP_VERSION' => 'version',
68
- 'HTTP_USER_AGENT' => 'user agent',
69
- 'HTTP_ACCEPT_ENCODING' => 'accept encoding',
70
- 'HTTP_ACCEPT' => 'accept'
71
- })
72
-
73
- issue_renderer.http_headers[:Version].must_equal 'version'
74
- issue_renderer.http_headers['User Agent'].must_equal 'user agent'
75
- issue_renderer.http_headers['Accept Encoding'].must_equal 'accept encoding'
76
- issue_renderer.http_headers[:Accept].must_equal 'accept'
77
- end
78
- end
79
-
80
- end
@@ -1,29 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe 'Rackless Issue Renderer' do
4
- before do
5
- @env = { :params => { :val1 => '1', :val2 => '2' }, :class => 'Worker', :method => 'perform' }
6
- end
7
-
8
- describe '#params' do
9
- before do
10
- @rendered_issue = PartyFoul::IssueRenderers::Rackless.new(nil, @env)
11
- end
12
-
13
- it 'returns the parameters' do
14
- @rendered_issue.params[:val1].must_equal '1'
15
- @rendered_issue.params[:val2].must_equal '2'
16
- end
17
- end
18
-
19
- describe '#raw_title' do
20
- before do
21
- @exception = Exception.new('message')
22
- @rendered_issue = PartyFoul::IssueRenderers::Rackless.new(@exception, @env)
23
- end
24
-
25
- it 'constructs the title with the controller and action' do
26
- @rendered_issue.send(:raw_title).must_equal %{Worker#perform (Exception) "message"}
27
- end
28
- end
29
- end
@@ -1,83 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe 'Rails Issue Renderer' do
4
- describe '#params' do
5
- let(:request_parameters) { { 'status' => 'ok', 'password' => 'test' } }
6
- before do
7
- @rendered_issue = PartyFoul::IssueRenderers::Rails.new(nil, {'action_dispatch.parameter_filter' => ['password'], 'action_dispatch.request.parameters' => request_parameters, 'QUERY_STRING' => { 'status' => 'fail' } })
8
- end
9
-
10
- it 'returns ok' do
11
- @rendered_issue.params['status'].must_equal 'ok'
12
- @rendered_issue.params['password'].must_equal '[FILTERED]'
13
- end
14
-
15
- context 'without request parameters' do
16
- let(:request_parameters) { nil }
17
-
18
- it 'returns empty hash' do
19
- @rendered_issue.params.must_equal({})
20
- end
21
- end
22
- end
23
-
24
- describe '#occurred_at' do
25
- it 'uses current when possible' do
26
- Time.stubs(:now).returns(Time.new(1970, 1, 1, 0, 0, 1, '-08:00'))
27
- Time.stubs(:current).returns(Time.new(1970, 1, 1, 0, 0, 1, '-05:00'))
28
- current_as_string = Time.current.strftime('%B %d, %Y %H:%M:%S %z')
29
- rendered_issue = PartyFoul::IssueRenderers::Rails.new(nil, nil)
30
- rendered_issue.occurred_at.must_equal current_as_string
31
- end
32
- end
33
-
34
- describe '#session' do
35
- let(:params) { {'action_dispatch.parameter_filter' => ['password'], 'rack.session' => { 'status' => 'ok', 'password' => 'test' }, 'QUERY_STRING' => { 'status' => 'fail' } } }
36
-
37
- before do
38
- @rendered_issue = PartyFoul::IssueRenderers::Rails.new(nil, params)
39
- end
40
-
41
- it 'returns ok' do
42
- @rendered_issue.session['status'].must_equal 'ok'
43
- @rendered_issue.session['password'].must_equal '[FILTERED]'
44
- end
45
-
46
- context "without session" do
47
-
48
- let(:params) { {'action_dispatch.parameter_filter' => ['password'], 'QUERY_STRING' => { 'status' => 'fail' } } }
49
-
50
- it 'returns empty hash' do
51
- @rendered_issue.session.must_be_empty
52
- end
53
- end
54
-
55
-
56
- end
57
-
58
- describe '#raw_title' do
59
- let(:request_parameters) { { 'controller' => 'landing', 'action' => 'index' } }
60
- before do
61
- @exception = Exception.new('message')
62
- controller_instance = mock('Controller')
63
- controller_instance.stubs(:class).returns('LandingController')
64
- env = {
65
- 'action_dispatch.request.parameters' => request_parameters,
66
- 'action_controller.instance' => controller_instance
67
- }
68
- @rendered_issue = PartyFoul::IssueRenderers::Rails.new(@exception, env)
69
- end
70
-
71
- it 'constructs the title with the controller and action' do
72
- @rendered_issue.send(:raw_title).must_equal %{LandingController#index (Exception) "message"}
73
- end
74
-
75
- context 'without request parameters' do
76
- let(:request_parameters) { nil }
77
-
78
- it 'leaves action blank' do
79
- @rendered_issue.send(:raw_title).must_equal %{LandingController# (Exception) "message"}
80
- end
81
- end
82
- end
83
- end
@@ -1,48 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe 'Party Foul Middleware' do
4
- include Rack::Test::Methods
5
-
6
- after do
7
- clean_up_party
8
- end
9
-
10
- def error_to_raise
11
- Exception
12
- end
13
-
14
- def app
15
- _self = self
16
- Rack::Builder.new {
17
- map '/' do
18
- use PartyFoul::Middleware
19
- run lambda { |env| raise _self.error_to_raise }
20
- end
21
- }
22
- end
23
-
24
- context 'handling an exception' do
25
- it 'does not handle exception' do
26
- PartyFoul::ExceptionHandler.stubs(:handle)
27
- PartyFoul::ExceptionHandler.expects(:handle)
28
- lambda {
29
- get '/'
30
- }.must_raise(Exception)
31
- end
32
- end
33
-
34
- context 'filtering based upon exception' do
35
- before do
36
- PartyFoul.blacklisted_exceptions = ['StandardError']
37
- self.stubs(:error_to_raise).returns(StandardError)
38
- end
39
-
40
- it 'does not handle exception' do
41
- PartyFoul::ExceptionHandler.stubs(:handle)
42
- PartyFoul::ExceptionHandler.expects(:handle).never
43
- lambda {
44
- get '/'
45
- }.must_raise(StandardError)
46
- end
47
- end
48
- end
@@ -1,33 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe 'Party Foul Rackless Exception Handler' do
4
- before do
5
- PartyFoul.configure do |config|
6
- config.oauth_token = 'abcdefg1234567890'
7
- config.owner = 'test_owner'
8
- config.repo = 'test_repo'
9
- end
10
- end
11
-
12
- describe '#handle' do
13
- it 'will call run on itself' do
14
- PartyFoul::RacklessExceptionHandler.any_instance.expects(:run)
15
- PartyFoul::RacklessExceptionHandler.handle(nil, {})
16
- end
17
-
18
- it 'should pass parameters required by the renderer to the initializer' do
19
- params = {:class => Object, :method => :to_s, :params => {:one => "One", :two => "Two"}}
20
- expected_exception_handler = PartyFoul::RacklessExceptionHandler.new(nil, params)
21
- expected_exception_handler.expects(:run)
22
- PartyFoul::RacklessExceptionHandler.expects(:new).with(nil, params).returns(expected_exception_handler)
23
- PartyFoul::RacklessExceptionHandler.handle(nil, params)
24
- end
25
- end
26
-
27
- describe '#initialize' do
28
- it 'should use PartyFoul::IssueRenderers::Rackless for rendering issues' do
29
- issue_renderer = PartyFoul::RacklessExceptionHandler.new(nil, {}).rendered_issue
30
- assert_kind_of(PartyFoul::IssueRenderers::Rackless, issue_renderer)
31
- end
32
- end
33
- end
@@ -1,42 +0,0 @@
1
- require 'bundler/setup'
2
-
3
- if defined?(M)
4
- require 'minitest/spec'
5
- else
6
- require 'minitest/autorun'
7
- end
8
- begin
9
- require 'byebug'
10
- rescue LoadError
11
- end
12
- require 'rack/test'
13
- require 'mocha/setup'
14
- require 'active_support'
15
- require 'party_foul'
16
-
17
- ActiveSupport.test_order = :random
18
-
19
- class MiniTest::Spec
20
- class << self
21
- alias :context :describe
22
- end
23
- end
24
-
25
- module MiniTest::Expectations
26
- infect_an_assertion :assert_received, :must_have_received
27
- end
28
-
29
- def clean_up_party
30
- %w{github oauth_token api_endpoint owner repo blacklisted_exceptions processor web_url branch additional_labels comment_limit}.each do |attr|
31
- PartyFoul.send("#{attr}=", nil)
32
- end
33
- end
34
-
35
- def sawyer_resource(attrs)
36
- agent = Sawyer::Agent.new(PartyFoul.api_endpoint)
37
- Sawyer::Resource.new(agent, attrs)
38
- end
39
-
40
- def no_search_results
41
- sawyer_resource(total_count: 0, incomplete_results: false, items: [])
42
- end
@@ -1,39 +0,0 @@
1
- PartyFoul.configure do |config|
2
- # The collection of exceptions PartyFoul should not be allowed to handle
3
- # The constants here *must* be represented as strings
4
- config.blacklisted_exceptions = ['ActiveRecord::RecordNotFound', 'ActionController::RoutingError']
5
-
6
- # The OAuth token for the account that is opening the issues on GitHub
7
- config.oauth_token = 'test_token'
8
-
9
- # The API endpoint for GitHub. Unless you are hosting a private
10
- # instance of Enterprise GitHub you do not need to include this
11
- config.api_endpoint = 'http://api.example.com'
12
-
13
- # The Web URL for GitHub. Unless you are hosting a private
14
- # instance of Enterprise GitHub you do not need to include this
15
- config.web_url = 'http://example.com'
16
-
17
- # The organization or user that owns the target repository
18
- config.owner = 'test_owner'
19
-
20
- # The repository for this application
21
- config.repo = 'test_repo'
22
-
23
- # The branch for your deployed code
24
- # config.branch = 'master'
25
-
26
- # Additional labels to add to issues created
27
- # config.additional_labels = ['production']
28
- # or
29
- # config.additional_labels = Proc.new do |exception, env|
30
- # []
31
- # end
32
-
33
- # Limit the number of comments per issue
34
- # config.comment_limit = 10
35
-
36
- # Setting your title prefix can help with
37
- # distinguishing the issue between environments
38
- # config.title_prefix = Rails.env
39
- end