Sha256: 38281894eb98b0d379cd93f0fb825fa29c2537810b487025d3a2f10b2b66603f

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

require 'test_helper'

class SpecifiedVersionKey < Test::Unit::TestCase
  context 'A model with a specified version key' do
    setup do
      @name = "Blah"
      @loser = Loser.create(:name => @name)
      @version = @loser.version
    end
    should 'be used for the initial version' do
      assert_equal @loser.revision, @loser.version
      assert_equal @loser.revision, @loser.versions.first.number
    end

    context 'after an update' do
      setup do
        @initial_version = @loser.version
        @initial_count = @loser.versions.count
        @initial_name = @loser.name
        @name = 'Blip'
        @loser.name = @name
        @loser.save
        @version = @loser.version
        @count = @loser.versions.count
      end

      should 'have a different version number' do
        assert_not_equal @initial_version, @loser.version
      end

      should 'still be using the specified key' do
        assert_equal @loser.revision, @loser.version
        assert_equal @loser.revision, @loser.versions.last.number
      end

      should 'version count should have increased by one' do
        assert_equal @initial_count + 1, @count
      end
      
      should 'revert properly' do
        @loser.revert
        @loser.save!
        assert_equal @initial_name, @loser.name
        assert_equal @count + 1, @loser.versions.count
        assert_not_equal @version, @loser.version
        assert_not_equal @initial_version, @loser.version
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
versioned-0.2.1 test/specified_version_key_test.rb
versioned-0.2.0 test/specified_version_key_test.rb
jacqui-versioned-0.1.1 test/specified_version_key_test.rb
mrkurt-versioned-0.1.1 test/specified_version_key_test.rb