Skip to content

Commit

Permalink
Polly wants a patcher
Browse files Browse the repository at this point in the history
  • Loading branch information
jomz committed Dec 18, 2008
1 parent 247fdd2 commit 4558e86
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/deep_cloning_test.rb
@@ -1,10 +1,11 @@
require File.dirname(__FILE__) + '/test_helper'

class DeepCloningTest < Test::Unit::TestCase
fixtures :pirates, :gold_pieces, :treasures, :mateys
fixtures :pirates, :gold_pieces, :treasures, :mateys, :parrots

def setup
@jack = Pirate.find(pirates(:jack).id)
@polly= Parrot.find(parrots(:polly).id)
end

def test_single_clone_exception
Expand Down Expand Up @@ -58,4 +59,10 @@ def test_multiple_and_deep_include_association_with_array
assert_equal 1, clone.gold_pieces.size
assert_equal 1, clone.mateys.size
end

def test_with_belongs_to_relation
clone = @jack.clone(:include => :parrot)
assert clone.save
assert_not_equal clone.parrot, @jack.parrot
end
end
3 changes: 3 additions & 0 deletions test/fixtures/parrot.rb
@@ -0,0 +1,3 @@
class Parrot < ActiveRecord::Base
belongs_to :pirate
end
3 changes: 3 additions & 0 deletions test/fixtures/parrots.yml
@@ -0,0 +1,3 @@
polly:
name: Polly
pirate_id: jack
1 change: 1 addition & 0 deletions test/fixtures/pirate.rb
Expand Up @@ -2,4 +2,5 @@ class Pirate < ActiveRecord::Base
has_many :mateys
has_many :treasures
has_many :gold_pieces, :through => :treasures
has_one :parrot
end
5 changes: 5 additions & 0 deletions test/schema.rb
Expand Up @@ -5,6 +5,11 @@
t.column :age, :string
end

create_table :parrots, :force => true do |t|
t.column :name, :string
t.column :pirate_id, :integer
end

create_table :mateys, :force => true do |t|
t.column :name, :string
t.column :pirate_id, :integer
Expand Down

0 comments on commit 4558e86

Please sign in to comment.