Skip to content

Commit 6b24f34

Browse files
authored
Autofix rich_text_list with 'elements' key having empty array by default (#1)
1 parent c4d3e6a commit 6b24f34

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/block_kit/layout/rich_text/list.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class RichText::List < BlockKit::Base
1111
].freeze
1212

1313
attribute :style, :string
14-
attribute :elements, Types::Array.of(RichText::Section)
14+
attribute :elements, Types::Array.of(RichText::Section), default: []
1515
attribute :indent, :integer
1616
attribute :offset, :integer
1717
attribute :border, :integer

spec/block_kit/layout/rich_text/list_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@
4242
]
4343
})
4444
end
45+
46+
context "when elements are not specified" do
47+
let(:attributes) { {style: :bullet} }
48+
49+
it "returns an empty elements array" do
50+
expect(block.as_json).to eq({
51+
type: described_class.type.to_s,
52+
style: "bullet",
53+
elements: []
54+
})
55+
end
56+
end
4557
end
4658

4759
context "attributes" do

0 commit comments

Comments
 (0)