Skip to content

Commit

Permalink
Merge 6484d6d into 80c3390
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhyman committed Mar 17, 2015
2 parents 80c3390 + 6484d6d commit 4528920
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/mongoid/attributes/processing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ def pending_nested
#
# @since 2.0.0.rc.7
def process_attribute(name, value)
if store_as = aliased_fields.invert[name.to_s]
name = store_as
end
responds = respond_to?("#{name}=")
raise Errors::UnknownAttribute.new(self.class, name) unless responds
send("#{name}=", value)
Expand Down
24 changes: 24 additions & 0 deletions spec/mongoid/copyable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@
end
end

context "when using store_as" do
context "and dynamic attributes are not set" do
it "clones" do
class StoreAsDupTest1
include Mongoid::Document
embeds_one :store_as_dup_test2, :store_as => :t
field :name
end

class StoreAsDupTest2
include Mongoid::Document
embedded_in :store_as_dup_test1
field :name
end

t = StoreAsDupTest1.new(:name => "hi")
t.build_store_as_dup_test2(:name => "there")
t.save
copy = t.__send__(method)
expect(copy.store_as_dup_test2.name).to eq(t.store_as_dup_test2.name)
end
end
end

context "when cloning a document with multiple languages field" do

before do
Expand Down

0 comments on commit 4528920

Please sign in to comment.