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

39 legacy connection handler #40

Merged
merged 5 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
102 changes: 57 additions & 45 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
grape-app (0.11.1)
grape-app (0.11.2)
activesupport
grape (>= 1.7)
grape-entity
Expand All @@ -14,68 +14,80 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activejob (7.0.7.2)
activesupport (= 7.0.7.2)
activejob (7.1.3)
activesupport (= 7.1.3)
globalid (>= 0.3.6)
activemodel (7.0.7.2)
activesupport (= 7.0.7.2)
activerecord (7.0.7.2)
activemodel (= 7.0.7.2)
activesupport (= 7.0.7.2)
activesupport (7.0.7.2)
activemodel (7.1.3)
activesupport (= 7.1.3)
activerecord (7.1.3)
activemodel (= 7.1.3)
activesupport (= 7.1.3)
timeout (>= 0.4.0)
activesupport (7.1.3)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.1.1)
base64 (0.2.0)
bigdecimal (3.1.6)
builder (3.2.4)
concurrent-ruby (1.2.2)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
diff-lcs (1.5.0)
dry-core (1.0.0)
drb (2.2.0)
ruby2_keywords
dry-core (1.0.1)
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
dry-inflector (1.0.0)
dry-logic (1.5.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dry-types (1.7.1)
dry-types (1.7.2)
bigdecimal (~> 3.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0)
dry-inflector (~> 1.0)
dry-logic (~> 1.4)
zeitwerk (~> 2.6)
globalid (1.1.0)
activesupport (>= 5.0)
grape (1.7.1)
activesupport
globalid (1.2.1)
activesupport (>= 6.1)
grape (2.0.0)
activesupport (>= 5)
builder
dry-types (>= 1.1)
mustermann-grape (~> 1.0.0)
rack (>= 1.3.0, < 3)
rack (>= 1.3.0)
rack-accept
grape-entity (1.0.0)
activesupport (>= 3.0.0)
multi_json (>= 1.3.2)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.3)
json (2.7.1)
language_server-protocol (3.17.0.3)
mini_portile2 (2.8.4)
minitest (5.19.0)
mini_portile2 (2.8.5)
minitest (5.21.2)
multi_json (1.15.0)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
mustermann-grape (1.0.2)
mustermann (>= 1.0.0)
openssl (3.1.0)
parallel (1.23.0)
parser (3.2.2.3)
mutex_m (0.2.0)
openssl (3.2.0)
parallel (1.24.0)
parser (3.3.0.4)
ast (~> 2.4.1)
racc
racc (1.7.1)
rack (2.2.8)
racc (1.7.3)
rack (3.0.8)
rack-accept (0.4.5)
rack (>= 0.4)
rack-cors (2.0.1)
Expand All @@ -84,8 +96,8 @@ GEM
rack-test (2.1.0)
rack (>= 1.3)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.8.1)
rake (13.1.0)
regexp_parser (2.9.0)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
Expand All @@ -100,47 +112,47 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rubocop (1.56.2)
base64 (~> 0.1.1)
rubocop (1.60.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-bsm (0.6.1)
rubocop (~> 1.0)
rubocop-performance
rubocop-rake
rubocop-rspec
rubocop-capybara (2.18.0)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-factory_bot (2.23.1)
rubocop (~> 1.33)
rubocop-performance (1.19.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-performance (1.20.2)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.23.2)
rubocop (~> 1.33)
rubocop-rspec (2.26.1)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sqlite3 (1.6.4)
sqlite3 (1.7.0)
mini_portile2 (~> 2.8.0)
thor (1.2.2)
thor (1.3.0)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
zeitwerk (2.6.11)
unicode-display_width (2.5.0)
zeitwerk (2.6.12)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion grape-app.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'grape-app'
s.version = '0.11.1'
s.version = '0.11.2'
s.authors = ['Black Square Media Ltd']
s.email = ['[email protected]']
s.summary = %(Standalone Grape API apps)
Expand Down
4 changes: 2 additions & 2 deletions lib/grape/app/helpers/caching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def fresh_when(object = nil, etag: nil, last_modified: nil, last_modified_field:
header 'Last-Modified', last_modified.httpdate if last_modified
cache_control(**cache_control) unless cache_control.empty?

if_modified_since = headers['If-Modified-Since']
if_modified_since = headers['if-modified-since']
if_modified_since = Time.rfc2822(if_modified_since) rescue nil if if_modified_since # rubocop:disable Style/RescueModifier
if_none_match = headers['If-None-Match']
if_none_match = headers['if-none-match']
return unless if_modified_since || if_none_match

fresh = true
Expand Down
8 changes: 1 addition & 7 deletions lib/grape/app/initializers/pre.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ActiveSupport::KeyGenerator.hash_digest_class = OpenSSL::Digest::SHA256 if ActiveSupport::KeyGenerator.respond_to?(:hash_digest_class=)
ActiveSupport::MessageEncryptor.use_authenticated_message_encryption = true
ActiveSupport::IsolatedExecutionState.isolation_level = :thread if defined?(ActiveSupport::IsolatedExecutionState)
Digest::UUID.use_rfc4122_namespaced_uuids = true if Digest::UUID.respond_to?(:use_rfc4122_namespaced_uuids=)
# Digest::UUID.use_rfc4122_namespaced_uuids = true if Digest::UUID.respond_to?(:use_rfc4122_namespaced_uuids=)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this one. Checking....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine, activesupport is using SecureRandom.uuid nowadays, this is legacy from when it used Digest::UUID directly. This changed in 7.1, but OK to keep as we support older activesupport versions too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just add a comment saying, this is legacy, removed with Rails 7.1 so we know in the future


# Set default time-zone
begin
Expand Down Expand Up @@ -43,12 +43,6 @@ def call(exception, *)
ActiveRecord::Base.default_timezone = :utc
end

if ActiveRecord.respond_to?(:legacy_connection_handling=)
ActiveRecord.legacy_connection_handling = false
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be an elsif. same here, we should support versions older than 7.1

ActiveRecord::Base.legacy_connection_handling = false
end

ActiveRecord.tap do |c|
c.verify_foreign_keys_for_fixtures = true if c.respond_to?(:verify_foreign_keys_for_fixtures=)
end
Expand Down
3 changes: 1 addition & 2 deletions spec/grape/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@ def app
if ActiveSupport::VERSION::MAJOR >= 7
expect(ActiveSupport::KeyGenerator.hash_digest_class).to be(OpenSSL::Digest::SHA256)
expect(ActiveSupport::IsolatedExecutionState.isolation_level).to be(:thread)
expect(Digest::UUID.use_rfc4122_namespaced_uuids).to be(true)
# expect(Digest::UUID.use_rfc4122_namespaced_uuids).to be(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the line completely

end
end

it 'configures ActiveRecord' do
if ActiveRecord::VERSION::MAJOR >= 7
expect(ActiveRecord.default_timezone).to be(:utc)
expect(ActiveRecord.legacy_connection_handling).to be(false)
expect(ActiveRecord.verify_foreign_keys_for_fixtures).to be(true)
expect(ActiveRecord::Base.partial_inserts).to be(false)
expect(ActiveRecord::Base.automatic_scope_inversing).to be(true)
Expand Down
Loading