]> git.openstreetmap.org Git - rails.git/blob - test/factories/traces.rb
JSON output, handle Accept header
[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     size { 10 }
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