test/functional/associations/test_many_proxy.rb in jnunemaker-mongomapper-0.3.3 vs test/functional/associations/test_many_proxy.rb in jnunemaker-mongomapper-0.3.4
- old
+ new
@@ -158,12 +158,12 @@
end
context "Finding scoped to association" do
setup do
@project1 = Project.new(:name => 'Project 1')
- @brand_new = Status.create(:name => 'New')
- @complete = Status.create(:name => 'Complete')
+ @brand_new = Status.create(:name => 'New', :position => 1 )
+ @complete = Status.create(:name => 'Complete', :position => 2)
@project1.statuses = [@brand_new, @complete]
@project1.save
@project2 = Project.create(:name => 'Project 2')
@in_progress = Status.create(:name => 'In Progress')
@@ -173,11 +173,11 @@
@project2.save
end
context "with :all" do
should "work" do
- @project1.statuses.find(:all).should == [@brand_new, @complete]
+ @project1.statuses.find(:all, :order => "position asc").should == [@brand_new, @complete]
end
should "work with conditions" do
statuses = @project1.statuses.find(:all, :conditions => {'name' => 'Complete'})
statuses.should == [@complete]
@@ -189,11 +189,11 @@
end
end
context "with #all" do
should "work" do
- @project1.statuses.all.should == [@brand_new, @complete]
+ @project1.statuses.all(:order => "position asc").should == [@brand_new, @complete]
end
should "work with conditions" do
statuses = @project1.statuses.all(:conditions => {'name' => 'Complete'})
statuses.should == [@complete]
@@ -227,22 +227,22 @@
end
end
context "with :last" do
should "work" do
- @project1.statuses.find(:last).should == @complete
+ @project1.statuses.find(:last, :order => "position asc").should == @complete
end
should "work with conditions" do
status = @project1.statuses.find(:last, :conditions => {:name => 'New'})
status.should == @brand_new
end
end
context "with #last" do
should "work" do
- @project1.statuses.last.should == @complete
+ @project1.statuses.last(:order => "position asc").should == @complete
end
should "work with conditions" do
status = @project1.statuses.last(:conditions => {:name => 'New'})
status.should == @brand_new
@@ -290,6 +290,6 @@
should "return the subject" do
@statuses.collect(&:name).should == %w(Archived Complete)
end
end
end
-end
\ No newline at end of file
+end