Skip to content

Commit 5411b51

Browse files
committed
Remove Rails 5/6 compatibility code
Since we now require Rails 7.0+, removed all EOL version checks: 1. spec/dummy/config/environments/test.rb (lines 19-25) Removed: if config.respond_to?(:public_file_server) check and else branch Justification: config.public_file_server was introduced in Rails 5.0. The old serve_static_files API was deprecated in Rails 5.0 and removed in Rails 5.1. Since we require Rails 7.0+, we can safely use public_file_server directly. Reference: https://guides.rubyonrails.org/5_0_release_notes.html 2. spec/dummy/config/initializers/wrap_parameters.rb (line 11) Removed: if respond_to?(:wrap_parameters) check Justification: wrap_parameters was introduced in Rails 3.1 (August 2011). This check was only needed for Rails 3.0 compatibility. Since we require Rails 7.0+, this method is always available. Reference: https://api.rubyonrails.org/v7.0/classes/ActionController/ParamsWrapper.html 3. spec/dummy/config/initializers/assets.rb (line 7) Removed: if Rails.application.config.respond_to?(:assets) check Justification: The assets config has been available since Rails 3.1 with the asset pipeline. This check was for Rails 3.0 compatibility. Even in Rails 7+ (where asset pipeline is optional), the config still exists. Reference: https://guides.rubyonrails.org/asset_pipeline.html 4. lib/vault/encrypted_model.rb (lines 332-340) Removed: Version checks for Rails 5.1, 5.2, and 6.0 change tracking APIs Justification: Rails 5.1 introduced saved_change_to_attribute?. Rails 5.2 added previous_changes_include? for deprecation transition. Rails 6.0 standardized on previous_changes.include?(). The old attribute_changed? API was deprecated in Rails 5.1 and removed in Rails 6.0. Since we require Rails 7.0+, we can use only previous_changes.include?(attribute). Reference: https://api.rubyonrails.org/v7.0/classes/ActiveModel/Dirty.html Migration guide: https://github.com/rails/rails/blob/v6.0.0/guides/source/6_0_release_notes.md
1 parent 1497b9c commit 5411b51

File tree

4 files changed

+5
-20
lines changed

4 files changed

+5
-20
lines changed

lib/vault/encrypted_model.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,7 @@ def __vault_persist_attribute!(attribute, options)
329329

330330
# Only persist changed attributes to minimize requests - this helps
331331
# minimize the number of requests to Vault.
332-
if ActiveRecord.gem_version >= Gem::Version.new("6.0")
333-
return unless previous_changes.include?(attribute)
334-
elsif ActiveRecord.gem_version >= Gem::Version.new("5.2")
335-
return unless previous_changes_include?(attribute)
336-
elsif ActiveRecord.gem_version >= Gem::Version.new("5.1")
337-
return unless saved_change_to_attribute?(attribute.to_s)
338-
else
339-
return unless attribute_changed?(attribute)
340-
end
332+
return unless previous_changes.include?(attribute)
341333

342334
# Get the current value of the plaintext attribute
343335
plaintext = attributes[attribute.to_s]

spec/dummy/config/environments/test.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,8 @@
1616
config.eager_load = false
1717

1818
# Configure static asset server for tests with Cache-Control for performance.
19-
if config.respond_to?(:public_file_server)
20-
config.public_file_server.enabled = true
21-
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
22-
else
23-
config.serve_static_files = true
24-
config.static_cache_control = 'public, max-age=3600'
25-
end
19+
config.public_file_server.enabled = true
20+
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
2621

2722
# Show full error reports and disable caching.
2823
config.consider_all_requests_local = true

spec/dummy/config/initializers/assets.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
# Be sure to restart your server when you modify this file.
55

66
# Version of your assets, change this if you want to expire all your assets.
7-
if Rails.application.config.respond_to?(:assets)
8-
Rails.application.config.assets.version = '1.0'
9-
end
7+
Rails.application.config.assets.version = '1.0'
108

119
# Precompile additional assets.
1210
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.

spec/dummy/config/initializers/wrap_parameters.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
1010
ActiveSupport.on_load(:action_controller) do
11-
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
11+
wrap_parameters format: [:json]
1212
end
1313

1414
# To enable root element in JSON for ActiveRecord objects.

0 commit comments

Comments
 (0)