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

Fix SchemaMigration parent class mismatch for Rails 7.1 #31

Merged
merged 1 commit into from
Oct 17, 2023
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased

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

## v1.8.2 - 2021-07-13
Expand Down
6 changes: 4 additions & 2 deletions lib/active_record/mass_assignment_security.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class ActiveRecord::Base
include ActiveRecord::MassAssignmentSecurity::Inheritance
end

class ActiveRecord::SchemaMigration < ActiveRecord::Base
attr_accessible :version
if ActiveRecord.version <= Gem::Version.new("7.0")
class ActiveRecord::SchemaMigration < ActiveRecord::Base
attr_accessible :version
end
end
8 changes: 1 addition & 7 deletions test/attribute_sanitization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,7 @@ def test_create_with_bang_with_without_protection_with_attr_protected_attributes
def test_protection_against_class_attribute_writers
attribute_writers = [:logger, :configurations, :primary_key_prefix_type, :table_name_prefix, :table_name_suffix, :pluralize_table_names,
:lock_optimistically, :default_scopes, :connection_handler, :nested_attributes_options,
:attribute_method_matchers, :time_zone_aware_attributes, :skip_time_zone_conversion_for_attributes]

if Rails::VERSION::MAJOR <= 6
attribute_writers += [:default_timezone, :schema_format, :timestamped_migrations]
end

attribute_writers.push(:_attr_readonly) if ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR == 0
:time_zone_aware_attributes, :skip_time_zone_conversion_for_attributes]

attribute_writers.each do |method|
assert_respond_to Task, method
Expand Down
Loading