Sha256: 115c6bbe51b212a59a527454fe3ad66ae92008736034bec46c18ba76b3204c0b

Contents?: true

Size: 864 Bytes

Versions: 73

Compression:

Stored size: 864 Bytes

Contents

require "spec_helper"

describe Mongoid::Timestamps::Created do

  describe ".included" do

    let(:quiz) do
      Quiz.new
    end

    let(:fields) do
      Quiz.fields
    end

    before do
      quiz.run_callbacks(:create)
      quiz.run_callbacks(:save)
    end

    it "adds created_at to the document" do
      expect(fields["created_at"]).to_not be_nil
    end

    it "does not add updated_at to the document" do
      expect(fields["updated_at"]).to be_nil
    end

    it "forces the created_at timestamps to UTC" do
      expect(quiz.created_at).to be_within(10).of(Time.now.utc)
    end
  end

  context "when the document is created" do

    let(:quiz) do
      Quiz.create
    end

    it "runs the created callbacks" do
      expect(quiz.created_at).to_not be_nil
      expect(quiz.created_at).to be_within(10).of(Time.now.utc)
    end
  end
end

Version data entries

73 entries across 68 versions & 6 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/gems/mongoid-6.4.0/spec/mongoid/timestamps/created_spec.rb
mongoid-7.0.0 spec/mongoid/timestamps/created_spec.rb
mongoid-6.4.0 spec/mongoid/timestamps/created_spec.rb
mongoid-6.3.0 spec/mongoid/timestamps/created_spec.rb
mongoid-6.2.1 spec/mongoid/timestamps/created_spec.rb
mongoid-7.0.0.beta spec/mongoid/timestamps/created_spec.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.1.0/spec/mongoid/timestamps/created_spec.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mongoid-6.1.0/spec/mongoid/timestamps/created_spec.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.2.0/spec/mongoid/timestamps/created_spec.rb
mongoid-6.2.0 spec/mongoid/timestamps/created_spec.rb
mongoid-6.1.1 spec/mongoid/timestamps/created_spec.rb
mongoid-5.2.1 spec/mongoid/timestamps/created_spec.rb
tdiary-5.0.4 vendor/bundle/gems/mongoid-6.1.0/spec/mongoid/timestamps/created_spec.rb
mongoid-6.1.0 spec/mongoid/timestamps/created_spec.rb
mongoid-5.2.0 spec/mongoid/timestamps/created_spec.rb
mongoid-5.2.0.rc0 spec/mongoid/timestamps/created_spec.rb
mongoid-6.1.0.rc0 spec/mongoid/timestamps/created_spec.rb
mongoid-6.0.3 spec/mongoid/timestamps/created_spec.rb
mongoid-5.1.6 spec/mongoid/timestamps/created_spec.rb
mongoid-6.0.2 spec/mongoid/timestamps/created_spec.rb