Sha256: 43bf91290ae4cfe5c2e6702495fc1d42adc068561eb2aee4ac69cbaa4e1f6764

Contents?: true

Size: 781 Bytes

Versions: 2

Compression:

Stored size: 781 Bytes

Contents

# encoding: utf-8

ENV["RAILS_ENV"] = "test"
require File.expand_path('../app/config/environment', __FILE__)
require 'rails/test_help'

require File.expand_path('../../lib/auto_increment', __FILE__)


config = YAML.load_file(File.dirname(__FILE__) + '/database.yml')
ActiveRecord::Base.establish_connection(config['test'])

ActiveRecord::Base.connection.create_table :accounts do |t|
  t.string :name
  t.date :code
end

ActiveRecord::Base.connection.create_table :users do |t|
  t.string :name
  t.integer :account_id
  t.string :letter_code
end


class Account < ActiveRecord::Base
  auto_increment

  has_many :users
end

class User < ActiveRecord::Base
  auto_increment :column => :letter_code, :scope => :account_id, :initial => 'A', :force => true

  belongs_to :account
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
auto_increment-1.0.0 test/test_helper.rb
auto_increment-0.2 test/test_helper.rb