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