X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/75c5d6619a7dbb79546dee5ebbb0a464b1fc9d41..8a4405dd0c3af7783d0cc9a4f864f4ee5cd0e71d:/test/factories/relation.rb diff --git a/test/factories/relation.rb b/test/factories/relation.rb index 1631b92de..8bb00e287 100644 --- a/test/factories/relation.rb +++ b/test/factories/relation.rb @@ -1,13 +1,28 @@ -FactoryGirl.define do +FactoryBot.define do factory :relation do - timestamp Time.now - visible true - version 1 + timestamp { Time.now } + visible { true } + version { 1 } changeset trait :deleted do - visible false + 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