Sha256: 9d72911def9107fec07b2d84151a73c29d9dcca386564dd5ae10d79b741907d9

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

require 'rubygems'
require 'spec'
require 'activerecord'
require 'rails/init'

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

Spec::Runner.configure do |config|
  
end

ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + '/debug.log')
ActiveRecord::Base.establish_connection(YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')))

class Database
  def self.reset!(with_from_version = false)
    ActiveRecord::Schema.define :version => 0 do
      create_table :books, :force => true do |t|
        t.integer :author_id
        t.integer :initial_version
        t.integer :from_version if with_from_version
        t.integer :version
        t.string :name
      end

      create_table :authors, :force => true do |t|
        t.integer :version, :default => 1
        t.string :name
      end
      
      Book.reset_column_information
    end
  end

end

class Book < ActiveRecord::Base
  belongs_to :author
  validates_associated :author
end

class Author < ActiveRecord::Base
  has_many :books, :extend => HasManyVersions
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
joshbuddy-has_many_versions-0.0.4 spec/spec_helper.rb
joshbuddy-has_many_versions-0.0.6 spec/spec_helper.rb
joshbuddy-has_many_versions-0.0.7 spec/spec_helper.rb
has_many_versions-0.0.7 spec/spec_helper.rb