Sha256: 655da46173df6c54e346ef19f21228a591454c5dcc5e7a3b2a69a01472de4705

Contents?: true

Size: 765 Bytes

Versions: 1

Compression:

Stored size: 765 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'

  belongs_to :account
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auto_increment-0.1 test/test_helper.rb