Skip to content

Add support for ruby 3 #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
@@ -9,6 +9,9 @@ jobs:
matrix:
ruby-version: [2.6, 2.7, 3.0]
rails-version: [5_2, 6_0, 6_1]
exclude:
- rails-version: 5_2
ruby-version: 3.0
fail-fast: false

# Service containers to run with `runner-job`
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,12 @@

### Bug fixes

## 1.1.1 (2021-10-08)

### Changes

- [#127](https://github.com/rootstrap/exception_hunter/pull/127) Upgrade to Pagy from 3.x to 4.x ([@megatux][])

## 1.1.0 (2021-07-30)

### New features
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ PATH
remote: .
specs:
exception_hunter (1.1.0)
pagy (~> 3)
pagy (~> 4)
slack-notifier (~> 2.3)

GEM
@@ -160,7 +160,7 @@ GEM
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
orm_adapter (0.5.0)
pagy (3.14.0)
pagy (4.11.0)
parallel (1.20.1)
parser (2.7.2.0)
ast (~> 2.4.1)
@@ -307,4 +307,4 @@ DEPENDENCIES
yard (~> 0.9.25)

BUNDLED WITH
2.1.4
2.2.28
16 changes: 8 additions & 8 deletions app/views/exception_hunter/errors/pagy/_pagy_nav.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<div class="error-occurrences__nav">
<%= link_to pagy_url_for(1, pagy) do %>
<%= button_tag 'First', class: %w[button button-outline error-occurrences__nav-link], disabled: pagy.prev.nil? %>
<%= link_to pagy_url_for(pagy, 1) do %>
<%= button_tag "First", class: %w[button button-outline error-occurrences__nav-link], disabled: pagy.prev.nil? %>
<% end %>
<%= link_to pagy_url_for(pagy.prev, pagy) do %>
<%= button_tag '<', class: %w[button button-outline error-occurrences__nav-link], disabled: pagy.prev.nil? %>
<%= link_to pagy_url_for(pagy, pagy.prev) do %>
<%= button_tag "<", class: %w[button button-outline error-occurrences__nav-link], disabled: pagy.prev.nil? %>
<% end %>
<div class="error-occurrences__nav-current">
<%= occurred_at %> (<%= pagy.page %>/<%= pagy.last %>)
</div>
<%= link_to pagy_url_for(pagy.next, pagy) do %>
<%= button_tag '>', class: %w[button button-outline error-occurrences__nav-link], disabled: pagy.next.nil? %>
<%= link_to pagy_url_for(pagy, pagy.next) do %>
<%= button_tag ">", class: %w[button button-outline error-occurrences__nav-link], disabled: pagy.next.nil? %>
<% end %>
<%= link_to pagy_url_for(pagy.last, pagy) do %>
<%= button_tag 'Last', class: %w[button button-outline error-occurrences__nav-link], disabled: pagy.next.nil? %>
<%= link_to pagy_url_for(pagy, pagy.last) do %>
<%= button_tag "Last", class: %w[button button-outline error-occurrences__nav-link], disabled: pagy.next.nil? %>
<% end %>
</div>
2 changes: 1 addition & 1 deletion exception_hunter.gemspec
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
EXCLUDED_FILES = %w[lib/tasks/code_analysis.rake].freeze
spec.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md'] - EXCLUDED_FILES

spec.add_dependency 'pagy', '~> 3'
spec.add_dependency 'pagy', '~> 4'
spec.add_dependency 'slack-notifier', '~> 2.3'

spec.add_development_dependency 'brakeman', '~> 4.8'
9 changes: 5 additions & 4 deletions lib/exception_hunter/error_creator.rb
Original file line number Diff line number Diff line change
@@ -29,17 +29,18 @@ def call(async_logging: Config.async_logging, tag: nil, **error_attrs)

def create_error(tag, error_attrs)
ActiveRecord::Base.transaction do
error_attrs = extract_user_data(error_attrs)
error_attrs = extract_user_data(**error_attrs)
error_attrs = hide_sensitive_values(error_attrs)
error = ::ExceptionHunter::Error.new(error_attrs)
error_group = ::ExceptionHunter::ErrorGroup.find_matching_group(error) || ::ExceptionHunter::ErrorGroup.new
update_error_group(error_group, error, tag)
error.error_group = error_group
error.save!
return if error_group.ignored?

notify(error)
error
unless error_group.ignored?
notify(error)
error
end
end
end

20 changes: 11 additions & 9 deletions spec/error_creator_spec.rb
Original file line number Diff line number Diff line change
@@ -42,18 +42,20 @@ module ExceptionHunter
expect { subject }.to change { error_group.reload.message }.to('Something went very wrong 123')
end

context 'with repeating tag' do
before do
error_attributes[:tag] = ErrorCreator::HTTP_TAG
described_class.call(error_attributes)
end
if RUBY_VERSION < '2.7'
context 'with repeating tag' do
before do
error_attributes[:tag] = ErrorCreator::HTTP_TAG
described_class.call(error_attributes)
end

it 'does not repeat tags' do
expect(error_group.reload.tags).to eq(['HTTP'])
it 'does not repeat tags' do
expect(error_group.reload.tags).to eq(['HTTP'])

subject
subject

expect(error_group.reload.tags).to eq(['HTTP'])
expect(error_group.reload.tags).to eq(['HTTP'])
end
end
end