Sha256: bdd02a39df8032ec5aa162a22dfe0d7a120df9b5294ae5e8f8dd71819e35bb94

Contents?: true

Size: 896 Bytes

Versions: 101

Compression:

Stored size: 896 Bytes

Contents

require 'cases/helper'
require 'models/topic'

class InvalidDateTest < Test::Unit::TestCase
  def test_assign_valid_dates
    valid_dates = [[2007, 11, 30], [1993, 2, 28], [2008, 2, 29]]

    invalid_dates = [[2007, 11, 31], [1993, 2, 29], [2007, 2, 29]]

    topic = Topic.new

    valid_dates.each do |date_src|
      topic = Topic.new("last_read(1i)" => date_src[0].to_s, "last_read(2i)" => date_src[1].to_s, "last_read(3i)" => date_src[2].to_s)
      assert_equal(topic.last_read, Date.new(*date_src))
    end

    invalid_dates.each do |date_src|
      assert_nothing_raised do
        topic = Topic.new({"last_read(1i)" => date_src[0].to_s, "last_read(2i)" => date_src[1].to_s, "last_read(3i)" => date_src[2].to_s})
        assert_equal(topic.last_read, Time.local(*date_src).to_date, "The date should be modified according to the behaviour of the Time object")
      end
    end
  end
end

Version data entries

101 entries across 98 versions & 20 rubygems

Version Path
activerecord-2.3.8.pre1 test/cases/invalid_date_test.rb
activerecord-2.3.7 test/cases/invalid_date_test.rb
activerecord-2.3.6 test/cases/invalid_date_test.rb
radiant-0.8.2 vendor/rails/activerecord/test/cases/invalid_date_test.rb
radiant-0.9.0.rc2 vendor/rails/activerecord/test/cases/invalid_date_test.rb
webroar-0.3.1 src/admin_panel/vendor/rails/activerecord/test/cases/invalid_date_test.rb
webroar-0.3.0 src/admin_panel/vendor/rails/activerecord/test/cases/invalid_date_test.rb
usher-0.7.0 spec/rails2_3/vendor/rails/vendor/rails/activerecord/pkg/activerecord-2.3.3/test/cases/invalid_date_test.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activerecord/pkg/activerecord-2.2.2/test/cases/invalid_date_test.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activerecord/test/cases/invalid_date_test.rb
usher-0.7.0 spec/rails2_3/vendor/rails/vendor/rails/activerecord/test/cases/invalid_date_test.rb
simply_stated-0.0.5 vendor/gems/ruby/1.8/gems/activerecord-2.3.5/test/cases/invalid_date_test.rb
simply_stated-0.0.4 vendor/gems/ruby/1.8/gems/activerecord-2.3.5/test/cases/invalid_date_test.rb
factorylabs-castronaut-0.7.5 vendor/activerecord/test/cases/invalid_date_test.rb
ginst-2009.12.8 vendor/rails/activerecord/test/cases/invalid_date_test.rb
activerecord-2.3.5 test/cases/invalid_date_test.rb
ginst-2009.11.24 vendor/rails/activerecord/test/cases/invalid_date_test.rb
ginst-2009.11.23 vendor/rails/activerecord/test/cases/invalid_date_test.rb
ginst-2.0.1 vendor/rails/activerecord/test/cases/invalid_date_test.rb
ginst-2.0.0 vendor/rails/activerecord/test/cases/invalid_date_test.rb