From 3360522fd8c6ad7eda6b36bb19c6e022a5d28b46 Mon Sep 17 00:00:00 2001 From: Patrick Oscity Date: Wed, 11 Sep 2024 22:00:47 +0200 Subject: [PATCH 1/4] Fix deprecated use of ActiveSupport::Deprecation singleton instance --- lib/grape-swagger-rails.rb | 10 ++++++++-- spec/features/swagger_spec.rb | 8 +++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/grape-swagger-rails.rb b/lib/grape-swagger-rails.rb index b56fefe..d63bab7 100644 --- a/lib/grape-swagger-rails.rb +++ b/lib/grape-swagger-rails.rb @@ -6,8 +6,10 @@ module GrapeSwaggerRails class Options < OpenStruct def before_filter(&block) - ActiveSupport::Deprecation.warn('This option is deprecated and going to be removed in 1.0.0. ' \ - 'Please use `before_action` instead') + GrapeSwaggerRails.deprecator.warn( + 'This option is deprecated and going to be removed in 1.0.0. ' \ + 'Please use `before_action` instead' + ) before_action(&block) end @@ -43,4 +45,8 @@ def before_action(&block) hide_url_input: false, hide_api_key_input: false ) + + def self.deprecator + @deprecator ||= ActiveSupport::Deprecation.new('1.0', 'GrapeSwaggerRails') + end end diff --git a/spec/features/swagger_spec.rb b/spec/features/swagger_spec.rb index 788f667..ff2d3b3 100644 --- a/spec/features/swagger_spec.rb +++ b/spec/features/swagger_spec.rb @@ -171,14 +171,16 @@ describe '#before_filter' do before do - allow(ActiveSupport::Deprecation).to receive(:warn) + allow(GrapeSwaggerRails.deprecator).to receive(:warn) end it 'throws deprecation warning' do GrapeSwaggerRails.options.before_filter { true } - expect(ActiveSupport::Deprecation).to have_received(:warn).with('This option is deprecated ' \ - 'and going to be removed in 1.0.0. Please use `before_action` instead') + expect(GrapeSwaggerRails.deprecator).to have_received(:warn).with( + 'This option is deprecated and going to be removed in 1.0.0. ' \ + 'Please use `before_action` instead' + ) end end From 0482856503b4728caaf191803231feca00a4b54c Mon Sep 17 00:00:00 2001 From: Patrick Oscity Date: Wed, 11 Sep 2024 22:09:47 +0200 Subject: [PATCH 2/4] Fix and update .rubocop_todo.yml --- .rubocop_todo.yml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7cb16d6..89734b3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-04-06 14:14:58 UTC using RuboCop version 1.62.1. +# on 2024-09-11 20:09:03 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -49,6 +49,7 @@ Metrics/BlockLength: # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS Naming/FileName: Exclude: + - 'Rakefile.rb' - 'lib/grape-swagger-rails.rb' - 'spec/features/grape-swagger-rails_spec.rb' @@ -61,7 +62,7 @@ RSpec/ContextWording: # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: SkipBlocks, EnforcedStyle. +# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. # SupportedStyles: described_class, explicit RSpec/DescribedClass: Exclude: @@ -72,13 +73,6 @@ RSpec/DescribedClass: RSpec/ExampleLength: Max: 8 -# Offense count: 1 -# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. -# Include: **/*_spec*rb*, **/spec/**/* -RSpec/FilePath: - Exclude: - - 'spec/features/grape-swagger-rails_spec.rb' - # Offense count: 2 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: @@ -124,9 +118,9 @@ Style/OpenStructUse: Exclude: - 'lib/grape-swagger-rails.rb' -# Offense count: 2 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https Layout/LineLength: - Max: 143 + Max: 124 From 3ee2abc0930755fa22067932a04f5477380e7168 Mon Sep 17 00:00:00 2001 From: Patrick Oscity Date: Wed, 11 Sep 2024 22:26:17 +0200 Subject: [PATCH 3/4] Fix specs by matching header names case-insensitively --- spec/features/swagger_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/features/swagger_spec.rb b/spec/features/swagger_spec.rb index ff2d3b3..34cbfc7 100644 --- a/spec/features/swagger_spec.rb +++ b/spec/features/swagger_spec.rb @@ -51,7 +51,7 @@ find_by_id('endpointListTogger_headers', visible: true).click first('span[class="http_method"] a', visible: true).click click_button 'Try it out!' - expect(page).to have_css 'span.hljs-attr', text: 'X-Test-Header' + expect(page).to have_css 'span.hljs-attr', text: /X-Test-Header/i expect(page).to have_css 'span.hljs-string', text: 'Test Value' end @@ -59,9 +59,9 @@ find_by_id('endpointListTogger_headers', visible: true).click first('span[class="http_method"] a', visible: true).click click_button 'Try it out!' - expect(page).to have_css 'span.hljs-attr', text: 'X-Test-Header' + expect(page).to have_css 'span.hljs-attr', text: /X-Test-Header/i expect(page).to have_css 'span.hljs-string', text: 'Test Value' - expect(page).to have_css 'span.hljs-attr', text: 'X-Another-Header' + expect(page).to have_css 'span.hljs-attr', text: /X-Another-Header/i expect(page).to have_css 'span.hljs-string', text: 'Another Value' end end @@ -108,7 +108,7 @@ find_by_id('endpointListTogger_headers', visible: true).click first('span[class="http_method"] a', visible: true).click click_button 'Try it out!' - expect(page).to have_css 'span.hljs-attr', text: 'Authorization' + expect(page).to have_css 'span.hljs-attr', text: /Authorization/i expect(page).to have_css 'span.hljs-string', text: "Basic #{Base64.encode64('username:password').strip}" end end @@ -127,7 +127,7 @@ find_by_id('endpointListTogger_headers', visible: true).click first('span[class="http_method"] a', visible: true).click click_button 'Try it out!' - expect(page).to have_css 'span.hljs-attr', text: 'Authorization' + expect(page).to have_css 'span.hljs-attr', text: /Authorization/i expect(page).to have_css 'span.hljs-string', text: 'Bearer token' end end @@ -146,7 +146,7 @@ find_by_id('endpointListTogger_headers', visible: true).click first('span[class="http_method"] a', visible: true).click click_button 'Try it out!' - expect(page).to have_css 'span.hljs-attr', text: 'Authorization' + expect(page).to have_css 'span.hljs-attr', text: /Authorization/i expect(page).to have_css 'span.hljs-string', text: 'Token token' end end From bdf63e0e95a672ff6de2faafbc1436cb53f4dcf6 Mon Sep 17 00:00:00 2001 From: Patrick Oscity Date: Wed, 11 Sep 2024 22:44:54 +0200 Subject: [PATCH 4/4] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81f102a..bb165f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ ### 0.5.1 (Next) +* [#124](https://github.com/ruby-grape/grape-swagger-rails/pull/124): Rails 7 compatibility - [@padde](https://github.com/padde). * Your contribution here. - + ### 0.5.0 (2024/04/06) * [#110](https://github.com/ruby-grape/grape-swagger-rails/pull/110): Update dummy app to current rails conventions - [@duffn](https://github.com/duffn).