Skip to content

Commit

Permalink
Add support for symbol_array type (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
timfjord authored and dlitvakb committed Oct 11, 2019
1 parent 27f10e8 commit 18f3205
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/contentful_model/migrations/content_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,16 @@ def management_link_type(type)
end

def management_items(type)
if %i[entry_array asset_array].include?(type.to_sym)
if %i[entry_array asset_array symbol_array].include?(type.to_sym)
array_type = type.split('_').first.capitalize

items = Contentful::Management::Field.new
items.type = 'Link'
items.link_type = type.split('_').first.capitalize
if %i[entry_array asset_array].include?(type.to_sym)
items.type = 'Link'
items.link_type = array_type
else
items.type = array_type
end

items
else
Expand Down
15 changes: 15 additions & 0 deletions spec/migrations/content_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@
expect(items.link_type).to eq('Asset')
end

it 'symbol array field' do
field = subject.field('foo', :symbol_array)

expect(field.id).to eq('foo')
expect(field.name).to eq('foo')
expect(field.type).to eq('Array')
expect(field.link_type).to eq(nil)

items = field.items

expect(items).to be_a(Contentful::Management::Field)
expect(items.type).to eq('Symbol')
expect(items.link_type).to eq(nil)
end

it 'rich_text field' do
field = subject.field('foo', :rich_text)

Expand Down

0 comments on commit 18f3205

Please sign in to comment.