Skip to content
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

Rails 7 compatibility; fix CI pipeline #124

Merged
merged 4 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
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
16 changes: 5 additions & 11 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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'

Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
10 changes: 8 additions & 2 deletions lib/grape-swagger-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
20 changes: 11 additions & 9 deletions spec/features/swagger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@
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

it 'supports multiple headers' do
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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
Loading