]> git.openstreetmap.org Git - rails.git/blob - test/factories/notes.rb
Merge pull request #6394 from openstreetmap/dependabot/github_actions/ruby/setup...
[rails.git] / test / factories / notes.rb
1 # frozen_string_literal: true
2
3 FactoryBot.define do
4   factory :note do
5     latitude { 1 * GeoRecord::SCALE }
6     longitude { 1 * GeoRecord::SCALE }
7     description { "Default note's description" }
8
9     trait :closed do
10       transient do
11         closed_by { nil }
12       end
13
14       status { "closed" }
15       closed_at { Time.now.utc }
16
17       after(:create) do |note, context|
18         create(:note_comment, :author => context.closed_by, :body => "Closing comment", :event => "closed", :note => note)
19       end
20     end
21
22     factory :note_with_comments do
23       transient do
24         comments_count { 1 }
25       end
26
27       after(:create) do |note, evaluator|
28         create(:note_comment, :event => "opened", :note => note)
29         create_list(:note_comment, evaluator.comments_count - 1, :note => note)
30       end
31     end
32   end
33 end