Permalink
Browse files

Create a failing test for multiple calls to #process_attributes when …

…a dynamic attribute is not a valid Ruby identifier
  • Loading branch information...
mzsanford committed Nov 27, 2012
1 parent ba4f54d commit 1a8f0c90d6a7d5fc83088871af954dd804011b55
Showing with 26 additions and 0 deletions.
  1. +26 −0 spec/mongoid/attributes/processing_spec.rb
@@ -115,6 +115,32 @@
it "updates the 1-n child" do
contractor.name.should eq("Jim")
end
+
+ context "with a key that is not a valid ruby identifier" do
+ let(:dynamic_updates) do
+ {
+ building_address: { :"postal-code" => "V8N 1A1" },
+ contractors: [{ :"license number" => "12345" }]
+ }
+ end
+
+ before do
+ building.process_attributes(dynamic_updates, :default, false)
+ end
+
+ it "updates the 1-1 child" do
+ building_address['postal-code'].should eq("V8N 1A1")
+ end
+
+ it "updates the 1-n child" do
+ contractor['license number'].should eq("12345")
+ end
+
+ it "correctly handles a second call to #process_attributes" do
+ building.process_attributes(dynamic_updates, :default, false)
+ end
+ end
+
end
end
end

0 comments on commit 1a8f0c9

Please sign in to comment.