Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2991

The .timeless operation is scoped to all objects within the timeless operation

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 4.0.0 final
    • Component/s: None
    • Labels:

      Description

      I believe .timeless is improperly scoped.

       ruby
      require 'spec_helper'
       
      class Chicken
        include Mongoid::Document
        include Mongoid::Timestamps
       
        after_save :lay_egg
       
        def lay_egg
          Egg.create!
        end
      end
       
      class Egg
        include Mongoid::Document
        include Mongoid::Timestamps
      end
       
       
      describe Mongoid do
        it "works" do
          Chicken.create!
          Egg.count.should == 1
          Egg.last.created_at.should_not be_nil
        end
        it "doesn't work" do
          Chicken.timeless.create!
          Egg.count.should == 1
          Egg.last.created_at.should_not be_nil
        end
      end
      

      When a chicken lays an egg, you would expect the egg to have a timestamp, even if the chicken doesn't have one.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: