Move constant to new concern to group labels together

This commit is contained in:
Jorge Manrubia
2025-04-04 12:18:03 +02:00
parent afcc65d6fb
commit de8a1120eb
4 changed files with 5 additions and 5 deletions
+3 -1
View File
@@ -8,10 +8,12 @@ module Account::PopReasons
"Working as intended"
]
FALLBACK_LABEL = "Done"
included do
has_many :pop_reasons, dependent: :destroy, class_name: "Pop::Reason" do
def labels
pluck(:label).presence || [ Pop::Reason::FALLBACK_LABEL ]
pluck(:label).presence || [ FALLBACK_LABEL ]
end
end
+1 -1
View File
@@ -3,6 +3,6 @@ class Pop < ApplicationRecord
belongs_to :user, optional: true
def reason
super || Pop::Reason::FALLBACK_LABEL
super || Account::PopReasons::FALLBACK_LABEL
end
end
-2
View File
@@ -1,5 +1,3 @@
class Pop::Reason < ApplicationRecord
belongs_to :account
FALLBACK_LABEL = "Done"
end
+1 -1
View File
@@ -1,4 +1,4 @@
require 'test_helper'
require "test_helper"
class PopReasonsTest < ActiveSupport::TestCase
test "create defaults pop reasons on creation" do