]> git.openstreetmap.org Git - rails.git/blobdiff - test/factories/traces.rb
Merge remote-tracking branch 'openstreetmap/pull/1449'
[rails.git] / test / factories / traces.rb
index 3f409b3675789144da8e291b24da4a00d3915d60..66f810468e20a1c81c8113bf1c92fa454c490044 100644 (file)
@@ -12,5 +12,20 @@ FactoryGirl.define do
     trait :deleted do
       visible false
     end
     trait :deleted do
       visible false
     end
+
+    transient do
+      fixture nil
+    end
+
+    after(:create) do |trace, evaluator|
+      if evaluator.fixture
+        File.symlink(Rails.root.join("test", "gpx", "fixtures", "#{evaluator.fixture}.gpx"),
+                     Rails.root.join("test", "gpx", "traces", "#{trace.id}.gpx"))
+        File.symlink(Rails.root.join("test", "gpx", "fixtures", "#{evaluator.fixture}.gif"),
+                     Rails.root.join("test", "gpx", "images", "#{trace.id}.gif"))
+        File.symlink(Rails.root.join("test", "gpx", "fixtures", "#{evaluator.fixture}_icon.gif"),
+                     Rails.root.join("test", "gpx", "images", "#{trace.id}_icon.gif"))
+      end
+    end
   end
 end
   end
 end