Sha256: bed0e08f5f4910e0ab4edf631e9f591f046ca048c7618a44167a4d6dd7ef4c41

Contents?: true

Size: 737 Bytes

Versions: 6

Compression:

Stored size: 737 Bytes

Contents

require_relative "helper"
require "override"
require_relative "../lib/ohm/timestamps"

class Person < Ohm::Model
  include Ohm::Timestamps
end

NOW = Time.utc(2010, 5, 12)

include Override

prepare do
  override(Time, now: NOW)
end

test "a new? record" do
  assert_equal nil, Person.new.created_at
  assert_equal nil, Person.new.updated_at
end

test "on create" do
  person = Person.create
  person = Person[person.id]

  assert_equal NOW, person.created_at
  assert_equal NOW, person.updated_at
end

test "on update" do
  person = Person.create

  override(Time, now: Time.utc(2010, 5, 13))
  person.save

  person = Person[person.id]

  assert_equal NOW, person.created_at
  assert_equal Time.utc(2010, 5, 13), person.updated_at
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ohm-contrib-3.0.0 test/timestamp.rb
ohm-contrib-2.2.0 test/timestamp.rb
ohm-contrib-2.0.1 test/timestamp.rb
ohm-contrib-2.0.0 test/timestamp.rb
ohm-contrib-2.0.0.rc2 test/timestamp.rb
ohm-contrib-2.0.0.rc1 test/timestamp.rb