Skip to content
Snippets Groups Projects
Commit 7e18bcbd authored by pabois's avatar pabois
Browse files

add tests to block migration

parent 7b7a2292
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,7 @@ class BlocksMigration
def self.clean_definitions
Communication::Block.where(template_kind: 'definitions').each do |block|
data = block['data']
if data && data['elements'].any? && data['elements'].first.has_key?('text')
if data && data.has_key?('elements') && data['elements'].any? && data['elements'].first.has_key?('text')
elements = []
data['elements'].each do |elmt|
elements << { title: elmt['title'], description: elmt['text'] }
......@@ -66,7 +66,7 @@ class BlocksMigration
def self.clean_gallery
Communication::Block.where(template_kind: 'gallery').each do |block|
data = block['data']
if data && data['elements'].any? && data['elements'].first.has_key?('file')
if data && data.has_key?('elements') && data['elements'].any? && data['elements'].first.has_key?('file')
elements = []
data['elements'].each do |elmt|
elements << { alt: elmt['alt'], text: elmt['text'], credit: elmt['credit'], image: elmt['file'] }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment