X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/d48603d9e07c24421309ccedbf554beea715115b..6b44a1976cf07ba50ba8aed8b34434e69a45e62d:/test/factories/way.rb?ds=sidebyside diff --git a/test/factories/way.rb b/test/factories/way.rb index 89409e807..68826e919 100644 --- a/test/factories/way.rb +++ b/test/factories/way.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :way do timestamp Time.now visible true @@ -10,6 +10,21 @@ FactoryGirl.define do visible false end + trait :with_history do + after(:create) do |way, _evaluator| + (1..way.version).each do |n| + create(:old_way, :way_id => way.id, :version => n, :changeset => way.changeset) + end + + # For deleted ways, make sure the most recent old_way is also deleted. + if way.visible == false + latest = way.old_ways.find_by(:version => way.version) + latest.visible = false + latest.save + end + end + end + factory :way_with_nodes do transient do nodes_count 1