Sha256: 0f14c2e539d49afe36d7749e23dbbf3892109be986a7ca450257f0989a5dee0f

Contents?: true

Size: 830 Bytes

Versions: 16

Compression:

Stored size: 830 Bytes

Contents

require_relative 'test_helper'
require 'stringio'

class MachineWithDifferentIntegerColumnDefaultTest < BaseTestCase
  def setup
    @original_stderr, $stderr = $stderr, StringIO.new

    @model = new_model do
      connection.add_column table_name, :status, :integer, :default => 0
    end
    @machine = StateMachines::Machine.new(@model, :status, :initial => :parked)
    @machine.state :parked, :value => 1
    @record = @model.new
  end

  def test_should_use_machine_default
    assert_equal 1, @record.status
  end

  def test_should_generate_a_warning
    assert_match(/Both Foo and its :status machine have defined a different default for "status". Use only one or the other for defining defaults to avoid unexpected behaviors\./, $stderr.string)
  end

  def teardown
    $stderr = @original_stderr
    super
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
state_machines-activerecord-0.9.0 test/machine_with_different_integer_column_default_test.rb
state_machines-activerecord-0.8.0 test/machine_with_different_integer_column_default_test.rb
state_machines-activerecord-0.6.0 test/machine_with_different_integer_column_default_test.rb
state_machines-activerecord-0.5.2 test/machine_with_different_integer_column_default_test.rb
state_machines-activerecord-0.5.1 test/machine_with_different_integer_column_default_test.rb
state_machines-activerecord-0.5.0 test/machine_with_different_integer_column_default_test.rb
state_machines-activerecord-0.4.1 test/machine_with_different_integer_column_default_test.rb
state_machines-activerecord-0.4.0 test/machine_with_different_integer_column_default_test.rb
state_machines-activerecord-0.4.0.pre test/machine_with_different_integer_column_default_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/state_machines-activerecord-0.2.0/test/machine_with_different_integer_column_default_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/state_machines-activerecord-0.2.0/test/machine_with_different_integer_column_default_test.rb
state_machines-activerecord-0.3.0 test/machine_with_different_integer_column_default_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/state_machines-activerecord-0.2.0/test/machine_with_different_integer_column_default_test.rb
state_machines-activerecord-0.2.0 test/machine_with_different_integer_column_default_test.rb
state_machines-activerecord-0.1.0 test/machine_with_different_integer_column_default_test.rb
state_machines-activerecord-0.0.1 test/machine_with_different_integer_column_default_test.rb