spec/integration/mongoid/i18n_spec.rb in mongoid_i18n-0.2.0 vs spec/integration/mongoid/i18n_spec.rb in mongoid_i18n-0.2.1

- old
+ new

@@ -25,10 +25,14 @@ describe "with an assigned value" do before do @entry = Entry.new(:title => 'Title') end + + it "should return that value" do + @entry.title.should == 'Title' + end describe "and persisted" do before do @entry.save end @@ -44,14 +48,10 @@ Entry.find(:first, :conditions => {:title => 'Title'}).should == @entry end end end - it "should return that value" do - @entry.title.should == 'Title' - end - describe "when the locale is changed" do before do I18n.locale = :es end @@ -69,42 +69,42 @@ end describe "persisted and retrieved from db" do before do @entry.save - @entry = Entry.find(:first, :conditions => {:title => 'Título'}) + @entry.reload end - it "the localized field value should be ok" do + it "the localized field value should be correct" do @entry.title.should == 'Título' I18n.locale = :en @entry.title.should == 'Title' @entry.title_translations.should == {'en' => 'Title', 'es' => 'Título'} end end - describe "getter.translations" do + describe "field_translations" do it "should return all translations" do @entry.title_translations.should == {'en' => 'Title', 'es' => 'Título'} end end - describe "getter.translations=" do + describe "with mass-assigned translations" do before do @entry.title_translations = {'en' => 'New title', 'es' => 'Nuevo título'} end - it "should accept new translations" do + it "should set all translations" do @entry.title_translations.should == {'en' => 'New title', 'es' => 'Nuevo título'} end it "the getter should return the new translation" do @entry.title.should == 'Nuevo título' end end - describe "and we go back to the original locale" do + describe "if we go back to the original locale" do before do I18n.locale = :en end it "should return the original value" do @@ -114,11 +114,11 @@ end end end end -describe Mongoid::I18n, 'criteria on embeds_many association' do +describe Mongoid::I18n, 'localized field in embedded association' do before do class Entry embeds_many :sub_entries end @@ -135,11 +135,11 @@ it "should contain the embedded documents" do @entry.sub_entries.criteria.instance_variable_get("@documents").should == @sub_entries end end -describe Mongoid::I18n, 'criteria on embeds_one association' do +describe Mongoid::I18n, 'localized field in embedded document' do before do class Entry embeds_one :sub_entry end @@ -148,15 +148,12 @@ include Mongoid::I18n localized_field :subtitle 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.create_sub_entry(:subtitle => "Oxford Street") - - @entry.reload - - @entry.sub_entry.subtitle.should == 'Oxford Street' + @entry.reload.sub_entry.subtitle.should == 'Oxford Street' end end \ No newline at end of file