Skip to content

Commit

Permalink
No need to save linked documents when appending to an association.
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Apr 25, 2011
1 parent db7bd34 commit 8cb2ec9
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 17 deletions.
1 change: 0 additions & 1 deletion ripple/lib/ripple/associations/linked.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def replace(value)
@reflection.verify_type!(value, @owner)
@owner.robject.links -= links
Array(value).compact.each do |doc|
doc.save if doc.new?
@owner.robject.links << doc.to_link(@reflection.link_tag)
end
loaded
Expand Down
1 change: 0 additions & 1 deletion ripple/lib/ripple/associations/many_linked_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def <<(value)
replace new_target
else
@reflection.verify_type!([value], @owner)
value.save if value.new?
@owner.robject.links << value.to_link(@reflection.link_tag)
appended_documents << value
@keys = nil
Expand Down
5 changes: 2 additions & 3 deletions ripple/spec/integration/ripple/nested_attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@
end

it "should save the children when saving the parent" do
subject.passengers.each do |passenger|
passenger.should_receive(:save)
end
subject.save
found_subject = Car.find(subject.key)
found_subject.passengers.map(&:name).should =~ %w[ Joe Sue Pat ]
end
end

Expand Down
6 changes: 0 additions & 6 deletions ripple/spec/ripple/associations/many_linked_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@
t.should == [@task]
end

it "should save unsaved documents when assigning" do
@task.should_receive(:new?).and_return(true)
@task.should_receive(:save).and_return(true)
@person.tasks = [@task]
end

it "should link-walk to the associated documents when accessing" do
@person.robject.links << @task.to_link("tasks")
@person.robject.should_receive(:walk).with(Riak::WalkSpec.new(:bucket => "tasks", :tag => "tasks")).and_return([])
Expand Down
6 changes: 0 additions & 6 deletions ripple/spec/ripple/associations/one_linked_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
ret.should == @profile
end

it "should save the new document when assigning" do
@profile.should_receive(:new?).and_return(true)
@profile.should_receive(:save).and_return(true)
@person.profile = @profile
end

it "should link-walk to the associated document when accessing" do
@person.robject.links << @profile.robject.to_link("profile")
@person.robject.should_receive(:walk).with(Riak::WalkSpec.new(:bucket => "profiles", :tag => "profile")).and_return([[@profile.robject]])
Expand Down

0 comments on commit 8cb2ec9

Please sign in to comment.