Sha256: 75be5c54dfe190dd96cb4432b18a526f977e152609052e869fa22b1aa852c892

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'rubygems'
require 'minitest/autorun'
require 'active_support/core_ext'
require 'active_record'
require 'better_ar'
require 'debugger'

class Object
  def must_be_like other
    self.gsub(/\s+/, ' ').strip.must_equal other.gsub(/\s+/, ' ').strip
  end
end

ActiveRecord::Base.establish_connection(
  :adapter => defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3',
  :database => ':memory:'
)

users_table = %{CREATE TABLE users (id INTEGER PRIMARY KEY, age INTEGER, name TEXT, object_type TEXT, object_id INTEGER);}
records_table = %{CREATE TABLE records (id INTEGER PRIMARY KEY, user_id INTEGER, name TEXT);}
reports_table = %{CREATE TABLE reports (id INTEGER PRIMARY KEY, record_id INTEGER, name TEXT);}
ActiveRecord::Base.connection.execute(users_table)
ActiveRecord::Base.connection.execute(records_table)
ActiveRecord::Base.connection.execute(reports_table)

class User < ActiveRecord::Base
  has_many :records
  belongs_to :object, :polymorphic => true
end

class Record < ActiveRecord::Base
  belongs_to :user
  has_many :reports
end

class Report < ActiveRecord::Base
  belongs_to :record
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
better_ar-0.1.1 test/helper.rb
better_ar-0.1.0 test/helper.rb