]> git.openstreetmap.org Git - rails.git/blob - test/factories/traces.rb
Add tile.openstreetmap.org to security policy
[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         FileUtils.copy(Rails.root.join("test", "gpx", "fixtures", "#{evaluator.fixture}.gpx"),
23                        File.join(Settings.gpx_trace_dir, "#{trace.id}.gpx"))
24         FileUtils.copy(Rails.root.join("test", "gpx", "fixtures", "#{evaluator.fixture}.gif"),
25                        File.join(Settings.gpx_image_dir, "#{trace.id}.gif"))
26         FileUtils.copy(Rails.root.join("test", "gpx", "fixtures", "#{evaluator.fixture}_icon.gif"),
27                        File.join(Settings.gpx_image_dir, "#{trace.id}_icon.gif"))
28       end
29     end
30   end
31 end