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

Ignore anonymous classes when calling sync_all! #5

Merged
merged 1 commit into from
May 2, 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.1.2

### Fixed

- Ignore anonymous ActiveRecord classes when calling `sync_all!`.

## 1.1.1

- Freeze values returned from helper methods.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.1
1.1.2
3 changes: 2 additions & 1 deletion lib/support_table_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ def support_table_classes(*extra_classes)
end
end

ActiveRecord::Base.descendants.sort_by(&:name).each do |klass|
active_record_classes = ActiveRecord::Base.descendants.reject { |klass| klass.name.nil? }
active_record_classes.sort_by(&:name).each do |klass|
next unless klass.include?(SupportTableData)
next if klass.abstract_class?
next if classes.include?(klass)
Expand Down
7 changes: 6 additions & 1 deletion spec/support_table_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,14 @@
expect(all_changes[Color]).to_not eq([])
end

it "can be called with a list of classes to inlude" do
it "can be called with a list of classes to include" do
expect { SupportTableData.sync_all!(Color) }.to_not raise_error
end

it "ignores anonomous classes" do
Class.new(ActiveRecord::Base)
expect { SupportTableData.sync_all! }.to_not raise_error
end
end

describe "named instances" do
Expand Down