Sha256: b49d1b749dfbae269ad55397ee934a83173a919c21c22d46df7279f0516ba932
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require File.dirname(__FILE__) + '/joinfix_test_helper' class HoMigration < ActiveRecord::Migration def self.up create_table :ho_parents do |t| t.column :field, :string end create_table :ho_children do |t| t.column :field, :string t.column :ho_parent_id, :integer t.column :alt_id, :integer end end def self.down drop_table :ho_parents drop_table :ho_children end end class HoParent < ActiveRecord::Base has_one :ho_child has_one :child, :foreign_key => "alt_id", :class_name => "HoChild" end class HoChild < ActiveRecord::Base end class HasOneTest < Test::Unit::TestCase fixtures :ho_parents, :ho_children def setup end def teardown end def test_has_one database_test(HoMigration) do entry = ho_parents(:without_child) assert_equal "without_child", entry.field assert_nil entry.ho_child assert_nil entry.child entry = ho_parents(:with_ho_child) assert_equal "with_ho_child", entry.field assert_equal "1", entry.ho_child.field entry = ho_parents(:with_child) assert_equal "with_child", entry.field assert_equal "2", entry.child.field end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
joinfix-0.1.0 | test/has_one_test.rb |