FIX: error customizing text for badges from plugins
This commit is contained in:
parent
22f11efad0
commit
9d781d4959
|
@ -181,7 +181,7 @@ class Badge < ActiveRecord::Base
|
|||
def self.find_system_badge_id_from_translation_key(translation_key)
|
||||
return unless translation_key.starts_with?('badges.')
|
||||
badge_name_klass = translation_key.split('.').second.camelize
|
||||
"Badge::#{badge_name_klass}".constantize
|
||||
Badge.const_defined?(badge_name_klass) ? "Badge::#{badge_name_klass}".constantize : nil
|
||||
end
|
||||
|
||||
def awarded_for_trust_level?
|
||||
|
|
|
@ -113,6 +113,14 @@ describe Badge do
|
|||
expect(Badge.find_system_badge_id_from_translation_key(translation_key)).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context "when translation key doesn't match its class" do
|
||||
let(:translation_key) { "badges.licensed.long_description" }
|
||||
|
||||
it "returns nil" do
|
||||
expect(Badge.find_system_badge_id_from_translation_key(translation_key)).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "First Quote" do
|
||||
|
|
Loading…
Reference in New Issue