Sha256: dcc591ae6b6bb03e8d553032e3db68846baef0a0564a9c446f16706a3ce0d28a
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') class Person < ActiveRecord::Base acts_as_enum :name_column => 'first_name' end describe ActiveEnum::ActsAsEnum do before(:all) do Person.create!(:first_name => 'Dave', :last_name => 'Smith') Person.create!(:first_name => 'John', :last_name => 'Doe') end it 'return name column value when passing id to [] method' do Person[1].should == 'Dave' end it 'return id column value when passing string name to [] method' do Person['Dave'].should == 1 Person['dave'].should == 1 end it 'return id column value when passing symbol name to [] method' do Person[:dave].should == 1 end it 'should return array for select helpers from to_select' do Person.to_select.should == [['Dave', 1], ['John', 2]] end it 'should return sorted array from order value for select helpers from to_select' do Person.class_eval do acts_as_enum :name_column => 'first_name', :order => :desc end Person.to_select.should == [['John', 2], ['Dave', 1]] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_enum-0.5.0 | spec/active_enum/acts_as_enum_spec.rb |