On postgres queries without an ORDER are ordered randomly, this caused
random spec failures

Dominik Sander 9 years ago
parent
commit
0daea40bdf
1 changed files with 5 additions and 6 deletions
  1. 5 6
      spec/models/agents/website_agent_spec.rb

+ 5 - 6
spec/models/agents/website_agent_spec.rb

@@ -379,13 +379,12 @@ describe Agents::WebsiteAgent do
379 379
             checker.check
380 380
           }.to change { Event.count }.by(2)
381 381
 
382
-          event = Event.all[-1]
383
-          expect(event.payload['version']).to eq(2.5)
384
-          expect(event.payload['title']).to eq("second")
382
+          (event2, event1) = Event.last(2)
383
+          expect(event1.payload['version']).to eq(2.5)
384
+          expect(event1.payload['title']).to eq("second")
385 385
 
386
-          event = Event.all[-2]
387
-          expect(event.payload['version']).to eq(2)
388
-          expect(event.payload['title']).to eq("first")
386
+          expect(event2.payload['version']).to eq(2)
387
+          expect(event2.payload['title']).to eq("first")
389 388
         end
390 389
 
391 390
         it "stores the whole object if :extract is not specified" do