Skip to content

Commit

Permalink
Change spec order to make it green again
Browse files Browse the repository at this point in the history
Not sure why, but after 2945bc5 the spec added to attributes_spec.rb made criteria_spec start failing, that only happens when running the entire test suite and under MRI
  • Loading branch information
arthurnn committed Dec 3, 2014
1 parent 90567ea commit 4a66796
Showing 1 changed file with 71 additions and 71 deletions.
142 changes: 71 additions & 71 deletions spec/mongoid/criteria_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,77 @@ class D

context "when including a belongs to relation" do

context "when the criteria is from the root" do

let!(:person_two) do
Person.create(age: 2)
end

let!(:post_one) do
person.posts.create(title: "one")
end

let!(:post_two) do
person_two.posts.create(title: "two")
end

context "when calling first" do

let(:criteria) do
Post.includes(:person)
end

let!(:document) do
criteria.first
end

it "eager loads the first document" do
expect_query(0) do
expect(document.person).to eq(person)
end
end

it "does not eager load the last document" do
doc = criteria.last
expect_query(1) do
expect(doc.person).to eq(person_two)
end
end

it "returns the first document" do
expect(document).to eq(post_one)
end
end

context "when calling last" do

let!(:criteria) do
Post.includes(:person)
end

let!(:document) do
criteria.last
end

it "eager loads the last document" do
expect_query(0) do
expect(document.person).to eq(person_two)
end
end

it "does not eager load the first document" do
doc = criteria.first
expect_query(1) do
expect(doc.person).to eq(person)
end
end

it "returns the last document" do
expect(document).to eq(post_two)
end
end
end

context "when the criteria is from an embedded relation" do

let(:peep) do
Expand Down Expand Up @@ -1495,77 +1566,6 @@ class D
end
end
end

context "when the criteria is from the root" do

let!(:person_two) do
Person.create(age: 2)
end

let!(:post_one) do
person.posts.create(title: "one")
end

let!(:post_two) do
person_two.posts.create(title: "two")
end

context "when calling first" do

let(:criteria) do
Post.includes(:person)
end

let!(:document) do
criteria.first
end

it "eager loads the first document" do
expect_query(0) do
expect(document.person).to eq(person)
end
end

it "does not eager load the last document" do
doc = criteria.last
expect_query(1) do
expect(doc.person).to eq(person_two)
end
end

it "returns the first document" do
expect(document).to eq(post_one)
end
end

context "when calling last" do

let!(:criteria) do
Post.includes(:person)
end

let!(:document) do
criteria.last
end

it "eager loads the last document" do
expect_query(0) do
expect(document.person).to eq(person_two)
end
end

it "does not eager load the first document" do
doc = criteria.first
expect_query(1) do
expect(doc.person).to eq(person)
end
end

it "returns the last document" do
expect(document).to eq(post_two)
end
end
end
end

context "when providing inclusions to the default scope" do
Expand Down

0 comments on commit 4a66796

Please sign in to comment.