X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/75c5d6619a7dbb79546dee5ebbb0a464b1fc9d41..f73b7205f42ac690ee659f4a92d86a56138a7ea2:/test/factories/way.rb?ds=sidebyside diff --git a/test/factories/way.rb b/test/factories/way.rb index 7c3531647..f2093e305 100644 --- a/test/factories/way.rb +++ b/test/factories/way.rb @@ -1,13 +1,40 @@ -FactoryGirl.define do +FactoryBot.define do factory :way do - timestamp Time.now - visible true - version 1 + timestamp { Time.now.utc } + visible { true } + version { 1 } changeset trait :deleted do - visible false + 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 } + end + + after(:create) do |way, evaluator| + (1..evaluator.nodes_count).each do |n| + create(:way_node, :way => way, :sequence_id => n) + end + end end end end