Fixes postgres and DST related spec issues

Dominik Sander 10 jaren geleden
bovenliggende
commit
842528ab3e
3 gewijzigde bestanden met toevoegingen van 19 en 14 verwijderingen
  1. 1 1
      spec/controllers/scenarios_controller_spec.rb
  2. 1 1
      spec/lib/huginn_scheduler_spec.rb
  3. 17 12
      spec/models/agent_spec.rb

+ 1 - 1
spec/controllers/scenarios_controller_spec.rb

@@ -28,7 +28,7 @@ describe ScenariosController do
28 28
 
29 29
     it "loads Agents for the requested Scenario" do
30 30
       get :show, :id => scenarios(:bob_weather).to_param
31
-      expect(assigns(:agents).pluck(:id)).to eq(scenarios(:bob_weather).agents.pluck(:id))
31
+      expect(assigns(:agents).pluck(:id).sort).to eq(scenarios(:bob_weather).agents.pluck(:id).sort)
32 32
     end
33 33
   end
34 34
 

+ 1 - 1
spec/lib/huginn_scheduler_spec.rb

@@ -107,7 +107,7 @@ describe Rufus::Scheduler do
107 107
     it 'registers active SchedulerAgents' do
108 108
       @scheduler.schedule_scheduler_agents
109 109
 
110
-      expect(@scheduler.scheduler_agent_jobs.map(&:scheduler_agent)).to eq([@agent1, @agent2])
110
+      expect(@scheduler.scheduler_agent_jobs.map(&:scheduler_agent).sort_by(&:id)).to eq([@agent1, @agent2])
111 111
     end
112 112
 
113 113
     it 'unregisters disabled SchedulerAgents' do

+ 17 - 12
spec/models/agent_spec.rb

@@ -561,12 +561,15 @@ describe Agent do
561 561
 
562 562
     describe "cleaning up now-expired events" do
563 563
       before do
564
-        @agent = Agents::SomethingSource.new(:name => "something")
565
-        @agent.keep_events_for = 5
566
-        @agent.user = users(:bob)
567
-        @agent.save!
568
-        @event = @agent.create_event :payload => { "hello" => "world" }
569
-        expect(@event.expires_at.to_i).to be_within(2).of(5.days.from_now.to_i)
564
+        @time = "2014-01-01 01:00:00 +00:00"
565
+        time_travel_to @time do
566
+          @agent = Agents::SomethingSource.new(:name => "something")
567
+          @agent.keep_events_for = 5
568
+          @agent.user = users(:bob)
569
+          @agent.save!
570
+          @event = @agent.create_event :payload => { "hello" => "world" }
571
+          expect(@event.expires_at.to_i).to be_within(2).of(5.days.from_now.to_i)
572
+        end
570 573
       end
571 574
 
572 575
       describe "when keep_events_for has not changed" do
@@ -584,12 +587,14 @@ describe Agent do
584 587
 
585 588
       describe "when keep_events_for is changed" do
586 589
         it "updates events' expires_at" do
587
-          expect {
588
-            @agent.options[:foo] = "bar1"
589
-            @agent.keep_events_for = 3
590
-            @agent.save!
591
-          }.to change { @event.reload.expires_at }
592
-          expect(@event.expires_at.to_i).to be_within(2).of(3.days.from_now.to_i)
590
+          time_travel_to @time do
591
+            expect {
592
+                @agent.options[:foo] = "bar1"
593
+                @agent.keep_events_for = 3
594
+                @agent.save!
595
+            }.to change { @event.reload.expires_at }
596
+            expect(@event.expires_at.to_i).to be_within(2).of(3.days.from_now.to_i)
597
+          end
593 598
         end
594 599
 
595 600
         it "updates events relative to their created_at" do