Sha256: 7a065f981872224ceedfc88f611813b9b438eb9a1e4dbcc087fd41a4abb4b58f

Contents?: true

Size: 976 Bytes

Versions: 3

Compression:

Stored size: 976 Bytes

Contents

require  File.dirname(__FILE__) + '/joinfix_test_helper'

#
# has_one tests
#

class HasOneMigration < 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
	end	
  end

  def self.down
	drop_table :ho_parents
	drop_table :ho_children
  end
end

class HoParent < ActiveRecord::Base
	has_one :ho_child
end

class HoChild < ActiveRecord::Base
end

class HasOneTest < Test::Unit::TestCase
	fixtures :ho_parents, :ho_children

	def test_has_one_with_options
		setup_fixtures(
:ho_parents  => %Q{
parent_entry:
 field: parent value
 ho_child:
   child_entry:
     field: child value},
:ho_children => "")

		assert_fixtures(
:ho_parents  => %Q{
parent_entry:
  id: 1
  field: parent value},
:ho_children => %Q{
child_entry:
  id: 1
  ho_parent_id: 1
  field: child value})
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
joinfix-0.1.1 test/has_one_test.rb
joinfix-1.0.0 test/has_one_test.rb
joinfix-1.0.1 test/has_one_test.rb