Sha256: 2b2295ede3e8b684481612adf9625c9fbcaf734e2bb08601101bb219c2d9494f

Contents?: true

Size: 1.61 KB

Versions: 2

Compression:

Stored size: 1.61 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

class VersionTest < Test::Unit::TestCase
  context 'Versions' do
    setup do
      @user = User.create(:name => 'Stephen Richert')
      @user.update_attribute(:name, 'Steve Jobs')
      @user.update_attribute(:last_name, 'Richert')
      @first_version, @last_version = @user.versions.first, @user.versions.last
    end

    should 'be comparable to another version based on version number' do
      assert @first_version == @first_version
      assert @last_version == @last_version
      assert @first_version != @last_version
      assert @last_version != @first_version
      assert @first_version < @last_version
      assert @last_version > @first_version
      assert @first_version <= @last_version
      assert @last_version >= @first_version
    end

    should "not equal a separate model's version with the same number" do
      user = User.create(:name => 'Stephen Richert')
      user.update_attribute(:name, 'Steve Jobs')
      user.update_attribute(:last_name, 'Richert')
      first_version, last_version = user.versions.first, user.versions.last
      assert_not_equal @first_version, first_version
      assert_not_equal @last_version, last_version
    end

    should 'default to ordering by number when finding' do
      order = VestalVersions::Version.send(:scope, :find)[:order]
      assert_equal 'versions.number ASC', order
    end

    should 'return true for the "initial?" method when the version number is 1' do
      version = @user.versions.build(:number => 1)
      assert_equal 1, version.number
      assert_equal true, version.initial?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vestal_versions-1.0.1 test/version_test.rb
vestal_versions-1.0.0 test/version_test.rb