]> git.openstreetmap.org Git - rails.git/blob - test/factories/traces.rb
Fixed "Tab alignment" issue described in #4773
[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.utc }
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(:build) do |user, evaluator|
21       if evaluator.fixture
22         user.file.attach(Rack::Test::UploadedFile.new(Rails.root.join("test", "gpx", "fixtures", "#{evaluator.fixture}.gpx")))
23
24         if evaluator.inserted
25           user.image.attach(Rack::Test::UploadedFile.new(Rails.root.join("test", "gpx", "fixtures", "#{evaluator.fixture}.gif")))
26           user.icon.attach(Rack::Test::UploadedFile.new(Rails.root.join("test", "gpx", "fixtures", "#{evaluator.fixture}_icon.gif")))
27         end
28       end
29     end
30   end
31 end