Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

Commit 05efa80

Browse files
committed
Fix SchemaMigration parent class mismatch for Rails 7.1
1 parent 45d065e commit 05efa80

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

CHANGELOG.md

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

33
## Unreleased
44

5-
* Nothing yet
5+
* [#31](https://github.com/westonganger/protected_attributes_continued/pull/31) - Fix SchemaMigration parent class mistmatch for Rails 7.1+
66
* [View Full Diff](https://github.com/westonganger/protected_attributes_continued/compare/v1.8.2...master)
77

88
## v1.8.2 - 2021-07-13

lib/active_record/mass_assignment_security.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class ActiveRecord::Base
2121
include ActiveRecord::MassAssignmentSecurity::Inheritance
2222
end
2323

24-
class ActiveRecord::SchemaMigration < ActiveRecord::Base
25-
attr_accessible :version
24+
if ActiveRecord.version <= Gem::Version.new("7.0")
25+
class ActiveRecord::SchemaMigration < ActiveRecord::Base
26+
attr_accessible :version
27+
end
2628
end

test/attribute_sanitization_test.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,7 @@ def test_create_with_bang_with_without_protection_with_attr_protected_attributes
254254
def test_protection_against_class_attribute_writers
255255
attribute_writers = [:logger, :configurations, :primary_key_prefix_type, :table_name_prefix, :table_name_suffix, :pluralize_table_names,
256256
:lock_optimistically, :default_scopes, :connection_handler, :nested_attributes_options,
257-
:attribute_method_matchers, :time_zone_aware_attributes, :skip_time_zone_conversion_for_attributes]
258-
259-
if Rails::VERSION::MAJOR <= 6
260-
attribute_writers += [:default_timezone, :schema_format, :timestamped_migrations]
261-
end
262-
263-
attribute_writers.push(:_attr_readonly) if ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR == 0
257+
:time_zone_aware_attributes, :skip_time_zone_conversion_for_attributes]
264258

265259
attribute_writers.each do |method|
266260
assert_respond_to Task, method

0 commit comments

Comments
 (0)