spec/unit/has_attachment_spec.rb in bulldog-0.2.1 vs spec/unit/has_attachment_spec.rb in bulldog-0.2.2

- old
+ new

@@ -49,9 +49,29 @@ Parent.attachment_reflections[:photo].styles[:two].should be_blank end end end + describe "assigning to an attachment" do + use_model_class(:Thing) + + describe "when assigning an existing attachment" do + before do + Thing.has_attachment :photo + @existing_thing = Thing.new(:photo => uploaded_file('test.jpg')) + @thing = Thing.new(:photo => @existing_thing.photo) + end + + it "should make a copy of the attachment" do + @thing.photo.value.should == @existing_thing.photo.value + end + + it "should ensure the copy points to the new record" do + @thing.photo.record.should equal(@thing) + end + end + end + describe ".attachment_reflections" do use_model_class(:Thing) it "should allow reflection on the field names" do Thing.has_attachment :photo