Commit 49539779 authored by James Lopez's avatar James Lopez

fix spec

parent eb55cb92
...@@ -23,16 +23,18 @@ module Projects ...@@ -23,16 +23,18 @@ module Projects
end end
def create_relations(relation_list = default_relation_list, tree_hash = @tree_hash) def create_relations(relation_list = default_relation_list, tree_hash = @tree_hash)
saved = []
relation_list.each do |relation| relation_list.each do |relation|
if relation.is_a?(Hash) if relation.is_a?(Hash)
create_sub_relations(relation, tree_hash) create_sub_relations(relation, tree_hash)
end end
relation_key = relation.is_a?(Hash) ? relation.keys.first : relation relation_key = relation.is_a?(Hash) ? relation.keys.first : relation
relation_hash = create_relation(relation_key, tree_hash[relation_key.to_s]) relation_hash = create_relation(relation_key, tree_hash[relation_key.to_s])
project.update_attribute(relation_key, relation_hash) saved << project.update_attribute(relation_key, relation_hash)
# FIXME # FIXME
# next if tree_hash[relation.to_s].blank? # next if tree_hash[relation.to_s].blank?
end end
saved.all?
end end
def default_relation_list def default_relation_list
...@@ -56,7 +58,7 @@ module Projects ...@@ -56,7 +58,7 @@ module Projects
relation.values.flatten.each do |sub_relation| relation.values.flatten.each do |sub_relation|
relation_hash = relation_item[sub_relation.to_s] relation_hash = relation_item[sub_relation.to_s]
next if relation_hash.blank? next if relation_hash.blank?
sub_relation_object = relation_from_factory(relation, relation_hash) sub_relation_object = relation_from_factory(sub_relation, relation_hash)
relation_item[sub_relation.to_s] = sub_relation_object relation_item[sub_relation.to_s] = sub_relation_object
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment