]> git.openstreetmap.org Git - rails.git/blobdiff - test/factories/way.rb
Remove all use of the :text option to render
[rails.git] / test / factories / way.rb
index 89409e807aa0a1088edd3b39ca61c5c3dea903f9..1c31de3d0316e1461f0a8a48acde79eb8efdc23d 100644 (file)
@@ -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