Sha256: 909c78ef20c0c6aa2f82184bd6195d30c8961dc89b0aa02b9de095d8e72cc012

Contents?: true

Size: 949 Bytes

Versions: 21

Compression:

Stored size: 949 Bytes

Contents

require 'test_helper'

class Superstore::TimestampsTest < Superstore::TestCase
  test 'timestamps set on create' do
    issue = Issue.create

    assert_in_delta Time.now.to_i, issue.created_at.to_i, 3
    assert_in_delta Time.now.to_i, issue.updated_at.to_i, 3
  end

  test 'updated_at set nil on change' do
    issue = Issue.create

    issue.updated_at = nil
    issue.description = 'lol'
    issue.save

    assert issue.updated_at.nil?
  end

  test 'updated_at can be set on change' do
    issue = Issue.create

    issue.update_attribute :updated_at, 30.days.ago

    assert_in_delta 30.days.ago.to_i, issue.updated_at.to_i, 3
  end

  test 'created_at sets only if nil' do
    time = 5.days.ago
    issue = Issue.create created_at: time

    assert_equal time, issue.created_at
  end

  test 'updated_at sets only if nil' do
    time = 5.days.ago
    issue = Issue.create updated_at: time

    assert_equal time, issue.updated_at
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
superstore-2.4.4 test/unit/timestamps_test.rb
superstore-2.4.3 test/unit/timestamps_test.rb
superstore-2.4.2 test/unit/timestamps_test.rb
superstore-2.4.1 test/unit/timestamps_test.rb
superstore-2.4.0 test/unit/timestamps_test.rb
superstore-2.3.0 test/unit/timestamps_test.rb
superstore-2.2.0 test/unit/timestamps_test.rb
superstore-2.1.3 test/unit/timestamps_test.rb
superstore-2.1.2 test/unit/timestamps_test.rb
superstore-2.1.1 test/unit/timestamps_test.rb
superstore-2.1.0 test/unit/timestamps_test.rb
superstore-2.0.1 test/unit/timestamps_test.rb
superstore-2.0.0 test/unit/timestamps_test.rb
superstore-1.2.0 test/unit/timestamps_test.rb
superstore-1.1.4 test/unit/timestamps_test.rb
superstore-1.1.3 test/unit/timestamps_test.rb
superstore-1.1.2 test/unit/timestamps_test.rb
superstore-1.1.1 test/unit/timestamps_test.rb
superstore-1.1.0 test/unit/timestamps_test.rb
superstore-1.0.12 test/unit/timestamps_test.rb