Permalink
Browse files

add update image spec

  • Loading branch information...
1 parent 2ddedb1 commit de0d423d5c924c4ffab24459724125f281fd2d4a @aklaiber aklaiber committed with rmm5t Mar 19, 2013
Showing with 8 additions and 1 deletion.
  1. +8 −1 spec/mongoid_spec.rb
View
@@ -676,7 +676,7 @@ def filename
end
@class.class_eval do
- embeds_many :mongo_locations
+ embeds_many :mongo_locations, cascade_callbacks: true
accepts_nested_attributes_for :mongo_locations
end
@@ -690,6 +690,13 @@ def filename
@doc.mongo_locations.first.image.path.should match(/old\.jpeg$/)
@embedded_doc.image.path.should match(/old\.jpeg$/)
end
+
+ it "should update the image on update_attributes" do
+ @doc.update_attributes(mongo_locations_attributes: [{id: @embedded_doc.id, image: stub_file("new.jpeg")}]).should be_true
+ @doc.reload
+ @doc.mongo_locations.first.image.path.should match(/new\.jpeg$/)
+ @embedded_doc.image.path.should match(/new\.jpeg$/)
+ end
end
end

0 comments on commit de0d423

Please sign in to comment.