Sha256: a4c2cb8332c6b553fd1aa74afcb29d92a759388811922c2c8c1d7208faf9da03

Contents?: true

Size: 722 Bytes

Versions: 2

Compression:

Stored size: 722 Bytes

Contents

require 'helper'

# Regression test for https://github.com/troessner/transitions/issues/95
class CreateSwitches < ActiveRecord::Migration
  def self.up
    create_table(:switches, force: true) do |t|
      t.string :state
    end
  end
end

class Switch < ActiveRecord::Base
  include ActiveModel::Transitions

  state_machine do
    state :off
    state :on
  end
end

class TestCustomSelect < Test::Unit::TestCase
  def setup
    set_up_db CreateSwitches
    Switch.create!
  end

  test 'should not trigger an exception when we use a custom select query which excludes the name of our state attribute' do
    result = Switch.select(:id)
    assert_nothing_raised NoMethodError do
      result.inspect
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
transitions-1.0.0 test/active_record/test_custom_select.rb
transitions-0.2.1 test/active_record/test_custom_select.rb