Skip to content

Commit 11bd5fe

Browse files
committed
Fixing feature images which had stopped rendering, and then adding test as it was not caught
1 parent 003eabb commit 11bd5fe

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

app/services/cms/providers/strapi/factories/model_factory.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ def self.to_enrichment(strapi_data)
119119
end
120120

121121
def self.to_featured_image(strapi_data, _all_data, size = :large)
122-
return nil if strapi_data[:data]
123-
122+
return nil unless strapi_data[:data][:attributes]
123+
image_data = strapi_data[:data][:attributes]
124124
{
125-
url: strapi_data[:url],
126-
alt: strapi_data[:alternativeText],
127-
caption: strapi_data[:caption],
128-
formats: strapi_data[:formats],
125+
url: image_data[:url],
126+
alt: image_data[:alternativeText],
127+
caption: image_data[:caption],
128+
formats: image_data[:formats],
129129
size:
130130
}
131131
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require "rails_helper"
2+
3+
RSpec.describe Cms::Models::Images::FeaturedImage do
4+
it "should render a Cms::ImageComponent" do
5+
@comp = Cms::Providers::Strapi::Factories::ModelFactory.process_model(
6+
{model: Cms::Models::Images::FeaturedImage, key: :featuredImage},
7+
{featuredImage: {data: Cms::Mocks::Images::Image.generate_raw_data}}
8+
)
9+
expect(@comp.render).to be_instance_of(FeaturedImageComponent)
10+
end
11+
end

0 commit comments

Comments
 (0)