From 9c2d3ca970adddbffc9edbe99bc4e974b0b960b1 Mon Sep 17 00:00:00 2001 From: Cristian Molina Date: Wed, 29 Sep 2021 19:39:21 -0300 Subject: [PATCH 1/5] Update Pagy & fix warnings --- Gemfile.lock | 6 +++--- .../errors/pagy/_pagy_nav.html.erb | 16 ++++++++-------- exception_hunter.gemspec | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 92f3f19..567648d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app/views/exception_hunter/errors/pagy/_pagy_nav.html.erb b/app/views/exception_hunter/errors/pagy/_pagy_nav.html.erb index 081d036..66a7da8 100644 --- a/app/views/exception_hunter/errors/pagy/_pagy_nav.html.erb +++ b/app/views/exception_hunter/errors/pagy/_pagy_nav.html.erb @@ -1,17 +1,17 @@
- <%= 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 %>
<%= occurred_at %> (<%= pagy.page %>/<%= pagy.last %>)
- <%= 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 %>
diff --git a/exception_hunter.gemspec b/exception_hunter.gemspec index 734ace2..ff0691f 100644 --- a/exception_hunter.gemspec +++ b/exception_hunter.gemspec @@ -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' From 681bf7eee2b03fc609a6f5eb29957140b8fadbbc Mon Sep 17 00:00:00 2001 From: Cristian Molina Date: Wed, 29 Sep 2021 19:40:45 -0300 Subject: [PATCH 2/5] Fix deprec. warning on ActiveRecord::Base.transaction --- lib/exception_hunter/error_creator.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/exception_hunter/error_creator.rb b/lib/exception_hunter/error_creator.rb index 2653011..a72fb99 100644 --- a/lib/exception_hunter/error_creator.rb +++ b/lib/exception_hunter/error_creator.rb @@ -36,10 +36,11 @@ def create_error(tag, error_attrs) 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 From 3c94c2a101c3dc308bc4e01d8bc42d33b149dc46 Mon Sep 17 00:00:00 2001 From: Cristian Molina Date: Fri, 8 Oct 2021 12:09:40 -0300 Subject: [PATCH 3/5] Update Changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 419abfb..be3ed6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From 2e94efd6962f97a059dcf9e3110598122cb42979 Mon Sep 17 00:00:00 2001 From: Federico Aldunate Date: Fri, 8 Oct 2021 18:31:14 -0300 Subject: [PATCH 4/5] Make this work with ruby 3 and exclude rails 5.2 with ruby 3 from the CI matrix --- .github/workflows/config.yml | 3 +++ lib/exception_hunter/error_creator.rb | 2 +- spec/error_creator_spec.rb | 20 +++++++++++--------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 4aff402..556266a 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -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` diff --git a/lib/exception_hunter/error_creator.rb b/lib/exception_hunter/error_creator.rb index a72fb99..87e9294 100644 --- a/lib/exception_hunter/error_creator.rb +++ b/lib/exception_hunter/error_creator.rb @@ -29,7 +29,7 @@ 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 diff --git a/spec/error_creator_spec.rb b/spec/error_creator_spec.rb index ae0b769..d88b94a 100644 --- a/spec/error_creator_spec.rb +++ b/spec/error_creator_spec.rb @@ -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 From ab4b1d2a352b9d4528f6475a490ae815e1e33194 Mon Sep 17 00:00:00 2001 From: Cristian Molina Date: Mon, 11 Oct 2021 12:36:06 -0300 Subject: [PATCH 5/5] Fix tests on Ruby3 Keyword args changes on Ruby v3 --- spec/error_creator_spec.rb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/spec/error_creator_spec.rb b/spec/error_creator_spec.rb index d88b94a..d46412b 100644 --- a/spec/error_creator_spec.rb +++ b/spec/error_creator_spec.rb @@ -42,20 +42,17 @@ module ExceptionHunter expect { subject }.to change { error_group.reload.message }.to('Something went very wrong 123') 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 + context 'with repeating tag' do + before do + described_class.call(tag: ErrorCreator::HTTP_TAG, **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']) - end + expect(error_group.reload.tags).to eq(['HTTP']) end end