basic specs for copying associations

pull/495/head
jwollert 11 years ago
parent af2c541930
commit b329665a73
  1. 29
      spec/lib/copy_model/copy_model_spec.rb

@ -66,10 +66,9 @@ class Relation3 < Tableless
end end
describe "Copying Models" do describe "Copying Models" do
describe "copying attributes" do
let(:dummy) { CopyDummy.new } let(:dummy) { CopyDummy.new }
describe "copying attributes" do
it "should copy safe attributes" do it "should copy safe attributes" do
dummy.safe_attribute1 = "foo" dummy.safe_attribute1 = "foo"
dummy.safe_attribute2 = "bar" dummy.safe_attribute2 = "bar"
@ -90,4 +89,30 @@ describe "Copying Models" do
dummy.unsafe_attribute.should_not == copy.unsafe_attribute dummy.unsafe_attribute.should_not == copy.unsafe_attribute
end end
end end
describe "copying associations" do
it "should copy associations, for which there are methods in our model" do
dummy.relation1 = Relation1.new
dummy.relation2 = Relation2.new
copy = CopyDummy.copy(dummy)
copy.relation1.should == dummy.relation1
copy.relation1.should_not == nil
copy.relation2.should == dummy.relation2
copy.relation2.should_not == nil
end
it "should not copy associations, for which there are no methods in our model" do
dummy.relation1 = Relation1.new
dummy.relation3 = Relation3.new
copy = CopyDummy.copy(dummy)
copy.relation1.should == dummy.relation1
copy.relation1.should_not == nil
copy.relation3.should_not == dummy.relation3
copy.relation3.should == nil
end
end
end end

Loading…
Cancel
Save