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

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

    • Type: Icon: Task Task
    • Resolution: Done
    • 4.0.0 final
    • Affects Version/s: None
    • Component/s: None

      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.

            Assignee:
            durran Durran Jordan
            Reporter:
            dblock Daniel Doubrovkine
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: