X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/1b7ab315bb7d241c5a0521f0810a0981e9031fc4..dbd88d893f3c3fce9cafd666b94396988646d81f:/test/factories/relation.rb diff --git a/test/factories/relation.rb b/test/factories/relation.rb index f53245c1b..44f18f491 100644 --- a/test/factories/relation.rb +++ b/test/factories/relation.rb @@ -5,5 +5,24 @@ FactoryGirl.define do version 1 changeset + + trait :deleted do + visible false + end + + trait :with_history do + after(:create) do |relation, _evaluator| + (1..relation.version).each do |n| + create(:old_relation, :relation_id => relation.id, :version => n, :changeset => relation.changeset) + end + + # For deleted relations, make sure the most recent old_relation is also deleted. + if relation.visible == false + latest = relation.old_relations.find_by(:version => relation.version) + latest.visible = false + latest.save + end + end + end end end