spec/integration/mongoid/i18n_spec.rb in mongoid_i18n-0.3.1 vs spec/integration/mongoid/i18n_spec.rb in mongoid_i18n-0.4.0
- old
+ new
@@ -3,10 +3,12 @@
class Entry
include Mongoid::Document
include Mongoid::I18n
+ field :weight, :type => Integer, :default => 60
+
localized_field :title
localized_field :title_with_default, :use_default_if_empty => true
localized_field :title_without_empty_values, :clear_empty_values => true
end
@@ -171,11 +173,11 @@
embedded_in :entry, :inverse_of => :sub_entries
end
@entry = Entry.new
@entry.create_sub_entry(:subtitle => 'Oxford Street')
end
-
+
it "should store the title in the right locale" do
@entry.reload.sub_entry.subtitle.should == 'Oxford Street'
end
end
@@ -360,7 +362,25 @@
end
it "no error for that field is added to entry errors list" do
@entry.errors.include?(:title_validated_with_all_locales).should be_false
end
+ end
+end
+
+describe Mongoid::I18n, "create_accessors" do
+ before do
+ I18n.locale = :en
+ @entry = Entry.new
+ end
+
+ it "should not affect other fields accessors" do
+ @entry.weight.should == 60
+
+ @entry.weight = 70
+ @entry.weight.should == 70
+ end
+
+ it "should not define own methods on for fields" do
+ @entry.should_not respond_to :weight_translations
end
end