Skip to content

Commit

Permalink
Add spec to ensure reload after id set works properly
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Aug 26, 2011
1 parent 1b51789 commit 5bc28b3
Showing 1 changed file with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@
end

it "deletes the document from the relation" do
# @todo: Durran:
# @todo: Durran:
reloaded.related.should be_empty
end

Expand Down Expand Up @@ -1813,6 +1813,39 @@
end
end

context "when setting the ids directly after the documents" do

let!(:person) do
Person.create!(:ssn => "132-11-1433", :title => "The Boss")
end

let!(:girlfriend_house) do
House.create!(:name => "Girlfriend")
end

let!(:wife_house) do
House.create!(:name => "Wife")
end

let!(:exwife_house) do
House.create!(:name => "Ex-Wife")
end

before do
person.update_attributes(
:houses => [ wife_house, exwife_house, girlfriend_house ]
)
person.update_attributes(:house_ids => [ girlfriend_house.id ])
end

context "when reloading" do

it "properly sets the references" do
person.houses(true).should eq([ girlfriend_house ])
end
end
end

context "when setting both sides in a single call" do

context "when the documents are new" do
Expand Down

0 comments on commit 5bc28b3

Please sign in to comment.