Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add spec for nested attribute

  • Loading branch information...
commit 2ddedb13191076707edceeaa948534cbfc22d954 1 parent bd16024
@aklaiber aklaiber authored rmm5t committed
Showing with 25 additions and 0 deletions.
  1. +25 −0 spec/mongoid_spec.rb
View
25 spec/mongoid_spec.rb
@@ -666,6 +666,31 @@ def filename
include_examples "double embedded documents"
end
end
+
+ describe 'with embedded documents and nested attributes' do
+ before do
+ @embedded_doc_class = define_mongo_class('MongoLocation') do
+ include Mongoid::Document
+ mount_uploader :image, @uploader
+ embedded_in :mongo_user
+ end
+
+ @class.class_eval do
+ embeds_many :mongo_locations
+ accepts_nested_attributes_for :mongo_locations
+ end
+
+ @doc = @class.new(mongo_locations_attributes: [{image: stub_file("old.jpeg")}])
+ @doc.save.should be_true
+ @embedded_doc = @doc.mongo_locations.first
+ end
+
+ it "should set the image on a save" do
+ @doc.reload
+ @doc.mongo_locations.first.image.path.should match(/old\.jpeg$/)
+ @embedded_doc.image.path.should match(/old\.jpeg$/)
+ end
+ end
end
describe '#mount_uploader removing old files with versions' do
Please sign in to comment.
Something went wrong with that request. Please try again.