Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ClassyEnum::Base.select_options now translates

This had gotten lost in a merge commit
  • Loading branch information...
commit af8f08aff2560f45b769771d8dfe3e0d9f4ae1ba 1 parent 63dfc47
@beerlington beerlington authored
Showing with 30 additions and 16 deletions.
  1. +1 −1  lib/classy_enum/collection.rb
  2. +29 −15 spec/classy_enum/translation_spec.rb
View
2  lib/classy_enum/collection.rb
@@ -106,7 +106,7 @@ def find(key=nil)
#
# Priority.select_options # => [["Low", "low"], ["Really High", "really_high"]]
def select_options
- map {|e| [e.to_s.titleize, e.to_s] }
+ map {|e| [e.text, e.to_s] }
end
end
View
44 spec/classy_enum/translation_spec.rb
@@ -9,35 +9,49 @@ class ClassyEnumTranslation::One < ClassyEnumTranslation
class ClassyEnumTranslation::Two < ClassyEnumTranslation
end
-class ClassyEnumTranslation::Three < ClassyEnumTranslation
-end
-
describe ClassyEnum::Translation do
- subject { ClassyEnumTranslation::One.new }
- before { I18n.reload! }
+ before do
+ I18n.reload!
+ I18n.backend.store_translations :en, :classy_enum => {:classy_enum_translation => {:one => 'One!', :two => 'Two!' } }
+ I18n.backend.store_translations :es, :classy_enum => {:classy_enum_translation => {:one => 'Uno', :two => 'Dos' } }
+ end
context '#text' do
+ subject { ClassyEnumTranslation::One.new }
+
context 'default' do
+ before { I18n.reload! }
its(:text) { should == 'One' }
end
context 'en' do
- before do
- I18n.locale = :en
- I18n.backend.store_translations :en, :classy_enum => {:classy_enum_translation => {:one => 'One!' } }
- end
-
+ before { I18n.locale = :en }
its(:text) { should == 'One!' }
end
context 'es' do
- before do
- I18n.locale = :es
- I18n.backend.store_translations :es, :classy_enum => {:classy_enum_translation => {:one => 'Uno' } }
- end
-
+ before { I18n.locale = :es }
its(:text) { should == 'Uno' }
end
end
+
+ context '.select_options' do
+ subject { ClassyEnumTranslation }
+
+ context 'default' do
+ before { I18n.reload! }
+ its(:select_options) { should == [["One", "one"], ["Two", "two"]] }
+ end
+
+ context 'en' do
+ before { I18n.locale = :en }
+ its(:select_options) { should == [["One!", "one"], ["Two!", "two"]] }
+ end
+
+ context 'es' do
+ before { I18n.locale = :es }
+ its(:select_options) { should == [["Uno", "one"], ["Dos", "two"]] }
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.