Fix handling of ActiveStorage::Attached::One #446
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this does
This fixes the same problem as #380, i.e. when you call
RubyLLM::Chat.ask
and pass aActiveStorage::Attached::One
object as thewith
parameter, it would try to callblobs
on the record instead ofblob
.The reason that this went unnoticed was that the test that was supposed to test it, didn't. 😀
In fact, the "handles multiple attachments" and "handles attachments in ask method" tests in
acts_as_attachment_spec.rb
were duplicates of the tests with the same names inacts_as_spec.rb
. Probably copy-pasted and then forgotten to adjust.I renamed and reordered the specs in
acts_as_spec
to make them easier to understand (but otherwise left the tests untouched) and renamed and rewrote the two tests inacts_as_attachment_spec.rb
, so that they actually test that passingActiveStorage::Attached::One
andActiveStorage::Attached::Many
objects work as expected.Unfortunately, the "handles ActiveStorage::Attached::Many in ask method" test fails locally for me with this error:
I suspect it's a problem with my local setup, but I can't even commit the failing test to git due to pre-commit hooks, so I don't know how to trigger CI with it to check if it passes. 🤷♂️
Type of change
Scope check
Quality check
overcommit --install
and all hooks passbundle exec rake vcr:record[provider_name]
bundle exec rspec
models.json
,aliases.json
)API changes
Related issues
#380