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
This commit is contained in:
rgarcia
2018-07-24 20:58:51 +02:00
committed by Javi Martín
parent 58aa861ef9
commit 68a2281203
7 changed files with 17 additions and 15 deletions

View File

@@ -215,7 +215,7 @@ describe "Admin Notifications", :admin do
end
scenario "Select list of users to send notification" do
UserSegments::SEGMENTS.each do |user_segment|
UserSegments.segments.each do |user_segment|
segment_recipient = I18n.t("admin.segment_recipient.#{user_segment}")
visit new_admin_admin_notification_path