Sha256: badf7f5fbe1fdda582fb4d7e7c456966b0aef5158a8ef51453de3ea3311dd67b

Contents?: true

Size: 849 Bytes

Versions: 14

Compression:

Stored size: 849 Bytes

Contents

require_relative '../helpers/test_helper'
require_relative 'configuration'

module Configuration
  class FinderTest < Minitest::Test
    def setup
      Enumerations.configure do |config|
        config.primary_key        = :id
        config.foreign_key_suffix = :id
      end
    end

    def teardown
      Enumerations.restore_default_configuration
    end

    def test_lookup_by_key
      enum = CustomEnum.find(:draft)

      assert_equal :draft, enum.symbol
    end

    def test_lookup_by_string_key
      enum = CustomEnum.find('draft')

      assert_equal :draft, enum.symbol
    end

    def test_lookup_by_primary_key
      enum = CustomEnum.find(1)

      assert_equal :draft, enum.symbol
    end

    def test_lookup_by_primary_key_as_string
      enum = CustomEnum.find('1')

      assert_equal :draft, enum.symbol
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
enumerations-2.6.0 test/configuration/finder_test.rb
enumerations-2.5.4 test/configuration/finder_test.rb
enumerations-2.5.3 test/configuration/finder_test.rb
enumerations-2.5.2 test/configuration/finder_test.rb
enumerations-2.5.1 test/configuration/finder_test.rb
enumerations-2.5.0 test/configuration/finder_test.rb
enumerations-2.4.0 test/configuration/finder_test.rb
enumerations-2.3.3 test/configuration/finder_test.rb
enumerations-2.3.2 test/configuration/finder_test.rb
enumerations-2.3.1 test/configuration/finder_test.rb
enumerations-2.2.3 test/configuration/finder_test.rb
enumerations-2.2.2 test/configuration/finder_test.rb
enumerations-2.2.1 test/configuration/finder_test.rb
enumerations-2.2.0 test/configuration/finder_test.rb