Sha256: 96c41337a6d90524b387f4c189940619ef63f575bb390fa996e4fc8293a267c3

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

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

#
# has_one with options
#

class HasOneWithOptionsMigration < ActiveRecord::Migration
  def self.up
	create_table :ho_with_options_parents do |t|
		t.column :field, :string
	end	
	create_table :ho_with_options_children do |t|
		t.column :field, :string
		t.column :alternate, :integer
	end	
  end

  def self.down
	drop_table :ho_with_options_parents
	drop_table :ho_with_options_children
  end
end

class HoWithOptionsParent < ActiveRecord::Base
	has_one :child, 
		:foreign_key => "alternate",
		:class_name => "HoWithOptionsChild"
end

class HoWithOptionsChild < ActiveRecord::Base
end

class HasOneWithOptionsTest < Test::Unit::TestCase
	fixtures :ho_with_options_parents, :ho_with_options_children

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

		assert_fixtures(
:ho_with_options_parents  => %Q{
parent_entry:
  id: 1
  field: parent value},
:ho_with_options_children => %Q{
child_entry:
  id: 1
  alternate: 1
  field: child value})
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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