docbrown/spec/models/articles/cached_entity_spec.rb
Jeremy Friesen 05bad3ae10
Replacing custom call with existing cached method (#16083)
There's a few things going on:

1. I introduced [a change][1].
2. There was a [data script][2] that should've completed successfully, but
   some data was not converted (see [Blazer query on DEV.to][3])

Thus the current state of the data means that we have have serialized
data in an `OpenStruct` format and `Articles::CachedEntity` format.

This patch should work because the OpenStruct should previously have an
`image_profile_90` attribute.

In addition, I have added some recommendations and tests to better
describe what's happening.

[1]:9780dba380/app/models/articles/cached_entity.rb (L4)
[2]:9780dba380/lib/data_update_scripts/20200723070918_update_articles_cached_entities.rb (L1)
[3]:https://dev.to/admin/blazer/queries/609-serialized-data-in-mixed-forms
2022-01-13 07:48:32 -05:00

9 lines
235 B
Ruby

require "rails_helper"
RSpec.describe Articles::CachedEntity, type: :model do
subject(:struct) { described_class.from_object(object) }
let(:object) { build(:user) }
it { is_expected.to respond_to(:profile_image_url_for) }
end