Created
January 21, 2012 00:42
-
-
Save danielspaniel/1650477 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec_helper" | |
describe Mongoid::Relations::Embedded::Many do | |
class Chef | |
include Mongoid::Document | |
embeds_many :menus | |
field :name | |
end | |
class Menu | |
include Mongoid::Document | |
embedded_in :chef | |
field :title | |
field :courses, type: Array | |
field :price, type: Integer | |
end | |
it "saves array field in embedded has_many" do | |
chef = Chef.create(:name => "dude") | |
old_menu = Menu.create(title: 'food', courses: ['fish', 'bread'], chef: chef) | |
new_menu = Menu.new(title: 'snacks', courses: ['soup', 'salad']) | |
old_menu.title = new_menu.title | |
old_menu.courses = new_menu.courses | |
old_menu.save | |
chef.reload.menus.first.courses.should == new_menu.courses | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment