Skip to content
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
7 changes: 5 additions & 2 deletions lib/fixture_kit/coders/active_record_coder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ def generate(parent_data: nil, &block)
model_name = name[NAME_PATTERN, :model_name]
next unless model_name

captured_models.add(ActiveSupport::Inflector.constantize(model_name))
klass = ActiveSupport::Inflector.safe_constantize(model_name)
next unless klass.is_a?(Class) && klass < ActiveRecord::Base

captured_models.add(klass)
end

ActiveSupport::Notifications.subscribed(subscriber, EVENT, monotonic: true, &block)
Expand All @@ -31,7 +34,7 @@ def mount(data)
connection.disable_referential_integrity do
# execute_batch is private in current supported Rails versions.
# This should be revisited when Rails 8.2 makes it public.
connection.__send__(:execute_batch, statements, "FixtureKit Load")
connection.__send__(:execute_batch, statements, "FixtureKit Insert")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/coders/active_record_coder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ def exercise_user_write_operations(suffix)
]

expect(primary_connection).to receive(:disable_referential_integrity).once.and_yield
expect(primary_connection).to receive(:execute_batch).with(primary_statements, "FixtureKit Load").once
expect(primary_connection).to receive(:execute_batch).with(primary_statements, "FixtureKit Insert").once
expect(analytics_connection).to receive(:disable_referential_integrity).once.and_yield
expect(analytics_connection).to receive(:execute_batch).with(analytics_statements, "FixtureKit Load").once
expect(analytics_connection).to receive(:execute_batch).with(analytics_statements, "FixtureKit Insert").once

coder.mount(records)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/fixture_cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ def identifier_for(identifier)
]

expect(primary_connection).to receive(:disable_referential_integrity).once.and_yield
expect(primary_connection).to receive(:execute_batch).with(primary_statements, "FixtureKit Load").once
expect(primary_connection).to receive(:execute_batch).with(primary_statements, "FixtureKit Insert").once
expect(analytics_connection).to receive(:disable_referential_integrity).once.and_yield
expect(analytics_connection).to receive(:execute_batch).with(analytics_statements, "FixtureKit Load").once
expect(analytics_connection).to receive(:execute_batch).with(analytics_statements, "FixtureKit Insert").once

expect(cache.load).to eq(:repository)
end
Expand Down
Loading