Files
nairobi/spec/factories/emails.rb
rgarcia 68a2281203 Refactor segment constant into a class method
We're going to make it dynamic using the geozones. Besides, class
methods can be overwritten using custom models, while constants can't be
overwritten without getting a warning [1].

Makes the definition of segments with geozones a little cleaner. I
think it’s worth it, compared to the slight memory gain of using a
constant [2].

[1] warning: already initialized constant UserSegments::SEGMENTS

[2] https://stackoverflow.com/questions/15903835/class-method-vs-constant-in-ruby-rails#answer-15903970
2021-12-20 15:07:25 +01:00

9 lines
257 B
Ruby

FactoryBot.define do
factory :newsletter do
sequence(:subject) { |n| "Subject #{n}" }
segment_recipient { UserSegments.segments.sample }
sequence(:from) { |n| "noreply#{n}@consul.dev" }
sequence(:body) { |n| "Body #{n}" }
end
end