Permalink
Browse files

Allow Marshal.dump on objects that only have polymorphic associations…

… where a polymorphic association is loaded

Was incorrectly matching to _dump
  • Loading branch information...
1 parent 46b51fc commit df5b6eb4488f6bf8bae588b642bc443bcd0a3d53 @gfguthrie committed Dec 13, 2012
@@ -32,7 +32,7 @@ def association_condition_details(name, last_condition = nil)
poly_type = nil
condition = nil
- if name_with_condition.to_s =~ /^(#{non_poly_assocs.collect(&:name).join("|")})_(\w+)$/
+ if name_with_condition.to_s =~ /^(#{non_poly_assocs.collect(&:name).join("|")})_(\w+)$/ && non_poly_assocs.present?
association_name = $1
condition = $2
elsif name_with_condition.to_s =~ /^(#{poly_assocs.collect(&:name).join("|")})_(\w+?)_type_(\w+)$/
@@ -217,4 +217,10 @@
user.orders.id_equals(order1.id).count.should == 1
user.orders.id_equals(order1.id).total_equals(2).count.should == 1
end
+
+ it "should allow Marshal.dump on objects that only have polymorphic associations where a polymorphic association is loaded" do
+ audit = Audit.create
+ audit.auditable = User.create
+ lambda { Marshal.dump(audit) }.should_not raise_error
+ end
end

0 comments on commit df5b6eb

Please sign in to comment.