spec/unit/assocations_spec.rb in couchrest_model-2.0.0.beta vs spec/unit/assocations_spec.rb in couchrest_model-2.0.0.beta2
- old
+ new
@@ -68,10 +68,15 @@
@invoice.client_id = nil
Client.should_not_receive(:get)
@invoice.client
end
+ it "should ignore blank ids" do
+ @invoice.client_id = ""
+ @invoice.client_id.should be_nil
+ end
+
it "should allow override of foreign key" do
@invoice.respond_to?(:alternate_client).should be_true
@invoice.respond_to?("alternate_client=").should be_true
@invoice.properties.find{|p| p.name == 'alt_client_id'}.should_not be_nil
end
@@ -112,9 +117,14 @@
it "should allow ids to be set directly and load entries" do
@invoice.entry_ids = @entries.collect{|i| i.id}
@invoice.entries.length.should eql(3)
@invoice.entries.first.should eql(@entries.first)
+ end
+
+ it "should ignore blank ids when set directly" do
+ @invoice.entry_ids = ["", @entries.first.id]
+ @invoice.entry_ids.length.should be(1)
end
it "should replace collection if ids replaced" do
@invoice.entry_ids = @entries.collect{|i| i.id}
@invoice.entries.length.should eql(3) # load once