Skip to content

Commit

Permalink
Merge pull request #9703 from alphagov/heros-without-content
Browse files Browse the repository at this point in the history
Support hero blocks without content
  • Loading branch information
richardTowers authored Dec 4, 2024
2 parents aa313b1 + 916b7a2 commit b2b10ec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/landing_page/block_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def self.build(block, images)
LandingPage::FeaturedBlock.new(block, images, blocks)
in { type: "hero", hero_content: { blocks: } }
LandingPage::HeroBlock.new(block, images, blocks)
in { type: "hero" }
LandingPage::HeroBlock.new(block, images, nil)
in { type: "image" }
LandingPage::ImageBlock.new(block, images)
in { type: String, blocks: Array }
Expand Down
21 changes: 21 additions & 0 deletions test/unit/app/models/landing_page/block_factory_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ class BlockFactoryTest < ActiveSupport::TestCase
assert_instance_of LandingPage::BaseBlock, block
end

test "#build builds hero blocks with content" do
images = []
config = {
"type" => "hero",
"image" => {},
"hero_content" => { "blocks" => [{ "type" => "some-type" }] },
}
block = LandingPage::BlockFactory.build(config, images)
assert_instance_of LandingPage::HeroBlock, block
end

test "#build builds hero blocks without content" do
images = []
config = {
"type" => "hero",
"image" => {},
}
block = LandingPage::BlockFactory.build(config, images)
assert_instance_of LandingPage::HeroBlock, block
end

test "#build_all builds blocks" do
images = []
blocks = LandingPage::BlockFactory.build_all([{ "type" => "some-type" }, { "type" => "some-type" }], images)
Expand Down

0 comments on commit b2b10ec

Please sign in to comment.