Sha256: 8862538412d8e4c585158331245353dc85a7b9367e3da37eb065700db11bba3d

Contents?: true

Size: 837 Bytes

Versions: 17

Compression:

Stored size: 837 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe Pupa::Concerns::Timestamps do
  let :klass do
    Class.new do
      include Pupa::Model
      include Pupa::Concerns::Timestamps

      def save
        run_callbacks(:save) do
          unless created_at
            run_callbacks(:create) do
            end
          end
        end
      end
    end
  end

  it 'should set created_at and updated_at on create' do
    object = klass.new
    object.save
    object.created_at.should be_within(1).of(Time.now.utc)
    object.updated_at.should be_within(1).of(Time.now.utc)
  end

  it 'should set updated_at on save' do
    object = klass.new(created_at: Time.new(2000))
    object.save
    object.created_at.should == Time.new(2000)
    object.updated_at.should be_within(1).of(Time.now.utc)
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pupa-0.1.11 spec/models/concerns/timestamps_spec.rb
pupa-0.1.10 spec/models/concerns/timestamps_spec.rb
pupa-0.1.9 spec/models/concerns/timestamps_spec.rb
pupa-0.1.8 spec/models/concerns/timestamps_spec.rb
pupa-0.1.7 spec/models/concerns/timestamps_spec.rb
pupa-0.1.6 spec/models/concerns/timestamps_spec.rb
pupa-0.1.5 spec/models/concerns/timestamps_spec.rb
pupa-0.1.4 spec/models/concerns/timestamps_spec.rb
pupa-0.1.3 spec/models/concerns/timestamps_spec.rb
pupa-0.1.2 spec/models/concerns/timestamps_spec.rb
pupa-0.1.1 spec/models/concerns/timestamps_spec.rb
pupa-0.1.0 spec/models/concerns/timestamps_spec.rb
pupa-0.0.13 spec/models/concerns/timestamps_spec.rb
pupa-0.0.12 spec/models/concerns/timestamps_spec.rb
pupa-0.0.11 spec/models/concerns/timestamps_spec.rb
pupa-0.0.10 spec/models/concerns/timestamps_spec.rb
pupa-0.0.9 spec/models/concerns/timestamps_spec.rb