]> git.openstreetmap.org Git - rails.git/blob - test/factories/traces.rb
66f810468e20a1c81c8113bf1c92fa454c490044
[rails.git] / test / factories / traces.rb
1 FactoryGirl.define do
2   factory :trace do
3     sequence(:name) { |n| "Trace #{n}.gpx" }
4     sequence(:description) { |n| "This is trace #{n}" }
5
6     # Fixme requires User Factory
7     user_id 1
8
9     timestamp Time.now
10     inserted true
11
12     trait :deleted do
13       visible false
14     end
15
16     transient do
17       fixture nil
18     end
19
20     after(:create) do |trace, evaluator|
21       if evaluator.fixture
22         File.symlink(Rails.root.join("test", "gpx", "fixtures", "#{evaluator.fixture}.gpx"),
23                      Rails.root.join("test", "gpx", "traces", "#{trace.id}.gpx"))
24         File.symlink(Rails.root.join("test", "gpx", "fixtures", "#{evaluator.fixture}.gif"),
25                      Rails.root.join("test", "gpx", "images", "#{trace.id}.gif"))
26         File.symlink(Rails.root.join("test", "gpx", "fixtures", "#{evaluator.fixture}_icon.gif"),
27                      Rails.root.join("test", "gpx", "images", "#{trace.id}_icon.gif"))
28       end
29     end
30   end
31 end