Skip to content

Commit

Permalink
Update dependencies (#130)
Browse files Browse the repository at this point in the history
* Update minitest

* Set test order to suppress warnings
* Set title_prefix in tests so tests work when run in random order

* Require ruby 2.1+

* Ruby 1.9.3 and 2.0.0 are no longer supported

* Update travis matrix

* Test ruby 2.4
* Update 2.3, 2.2, & 2.1 dot versions
* Drop 1.9.3, 2.0

* Do not memoize octokit client

* Memoization prevents updating the Octokit Client settings if
configure is called more than once (like in the tests)
* Remove unnecessary block argument

* Fix ruby redefinition warnings

* Reader methods for :branch, :web_url, etc are overridden

* Fix intermittent test failures

* Reset configuration

* Remove overridden body attr_reader

*#body is defined below
* Fixes ruby warning

* Remove unused line. Fix warning
  • Loading branch information
teeparham authored and alexanderadam committed Feb 26, 2018
1 parent a459132 commit 1a3b40c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 26 deletions.
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ language: ruby
sudo: false
cache: bundler
rvm:
- 2.0.0
- 2.1.8
- 2.2.4
- 2.3.0
- 1.9.3
- 2.4.0
- 2.3.3
- 2.2.6
- 2.1
- ruby-head
matrix:
allow_failures:
- rvm: 1.9.3
- rvm: ruby-head
notifications:
email:
Expand Down
7 changes: 4 additions & 3 deletions lib/party_foul.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

module PartyFoul
class << self
attr_accessor :github, :oauth_token, :api_endpoint, :owner, :repo, :blacklisted_exceptions, :processor, :web_url, :branch, :additional_labels, :comment_limit, :title_prefix
attr_accessor :github, :oauth_token, :owner, :repo, :additional_labels, :comment_limit, :title_prefix
attr_writer :branch, :web_url, :api_endpoint, :processor, :blacklisted_exceptions
end

# The git branch that is used for linking in the stack trace
Expand Down Expand Up @@ -78,9 +79,9 @@ def self.repo_url
# Will also setup for GitHub api connections
#
# @param [Block]
def self.configure(&block)
def self.configure
yield self
self.github ||= Octokit::Client.new access_token: oauth_token, api_endpoint: api_endpoint
self.github = Octokit::Client.new access_token: oauth_token, api_endpoint: api_endpoint
end
end

Expand Down
1 change: 0 additions & 1 deletion lib/party_foul/issue_renderers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

class PartyFoul::IssueRenderers::Base
attr_accessor :exception, :env, :sha
attr_reader :body

# A new renderer instance for GitHub issues
#
Expand Down
4 changes: 2 additions & 2 deletions party_foul.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.description = 'Auto-submit Rails exceptions as new issues on GitHub'
s.license = 'MIT'

s.required_ruby_version = '>= 1.9.3'
s.required_ruby_version = '>= 2.1.0'

s.files = Dir['{app,config,db,lib}/**/*'] + ['Rakefile', 'README.md']
s.test_files = Dir['test/**/*']
Expand All @@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'actionpack', '~> 4.0'
s.add_development_dependency 'activesupport', '~> 4.0'
s.add_development_dependency 'railties', '~> 4.0'
s.add_development_dependency 'minitest', '~> 4.7'
s.add_development_dependency 'minitest', '~> 5.8'
s.add_development_dependency 'webmock'
s.add_development_dependency 'rack-test'
s.add_development_dependency 'mocha'
Expand Down
4 changes: 1 addition & 3 deletions test/party_foul/exception_handler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@
end

it "doesn't post a comment if the limit has been met" do
PartyFoul.configure do |config|
config.comment_limit = 10
end
PartyFoul.comment_limit = 10
PartyFoul::ExceptionHandler.any_instance.expects(:occurrence_count).returns(10)
PartyFoul.github.expects(:add_comment).never
PartyFoul::ExceptionHandler.new(nil, {}).run
Expand Down
27 changes: 18 additions & 9 deletions test/party_foul/issue_renderers/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,24 @@
end

describe '#title' do
it 'masks the object ids in the raw_title' do
rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
rendered_issue.stubs(:raw_title).returns('Error for #<ClassName:0xabcdefg1234567>')
rendered_issue.title.must_equal 'Error for #<ClassName:0xXXXXXX>'
end
context 'when no title prefix is configured' do
before do
PartyFoul.configure do |config|
config.title_prefix = nil
end
end

it 'masks the extended object ids in the raw_title' do
rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
rendered_issue.stubs(:raw_title).returns('Error for #<#<ClassName:0x007fbddbdcd340>:0x007fbddf6be0a0>')
rendered_issue.title.must_equal 'Error for #<#<ClassName:0xXXXXXX>:0xXXXXXX>'
it 'masks the object ids in the raw_title' do
rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
rendered_issue.stubs(:raw_title).returns('Error for #<ClassName:0xabcdefg1234567>')
rendered_issue.title.must_equal 'Error for #<ClassName:0xXXXXXX>'
end

it 'masks the extended object ids in the raw_title' do
rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
rendered_issue.stubs(:raw_title).returns('Error for #<#<ClassName:0x007fbddbdcd340>:0x007fbddf6be0a0>')
rendered_issue.title.must_equal 'Error for #<#<ClassName:0xXXXXXX>:0xXXXXXX>'
end
end

context 'when a custom title prefix is configured' do
Expand Down Expand Up @@ -178,6 +186,7 @@
end

it 'formats the stack trace with link to shortened application path' do
clean_up_party
exception = mock do
stubs backtrace: ['/path/to/app/lib/some/file.rb:123 in `method`']
end
Expand Down
1 change: 0 additions & 1 deletion test/party_foul/issue_renderers/rails_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
Time.stubs(:current).returns(Time.new(1970, 1, 1, 0, 0, 1, '-05:00'))
current_as_string = Time.current.strftime('%B %d, %Y %H:%M:%S %z')
rendered_issue = PartyFoul::IssueRenderers::Rails.new(nil, nil)
expected = rendered_issue.occurred_at
rendered_issue.occurred_at.must_equal current_as_string
end
end
Expand Down
4 changes: 3 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
end
require 'rack/test'
require 'mocha/setup'
require 'active_support'
require 'party_foul'

ActiveSupport.test_order = :random

class MiniTest::Spec
class << self
Expand All @@ -37,4 +39,4 @@ def sawyer_resource(attrs)

def no_search_results
sawyer_resource(total_count: 0, incomplete_results: false, items: [])
end
end

0 comments on commit 1a3b40c

Please sign in to comment.