spec/lib/flapjack/web_spec.rb in flapjack-0.6.39 vs spec/lib/flapjack/web_spec.rb in flapjack-0.6.40
- old
+ new
@@ -16,11 +16,12 @@
let(:entity) { mock(Flapjack::Data::Entity) }
let(:entity_check) { mock(Flapjack::Data::EntityCheck) }
before(:each) do
- Flapjack::Web.class_variable_set('@@redis', @redis)
+ Flapjack::RedisPool.should_receive(:new).and_return(@redis)
+ Flapjack::Web.bootstrap(:config => {})
end
def expect_stats
@redis.should_receive(:keys).with('*').and_return([])
@redis.should_receive(:zcard).with('failed_checks')
@@ -167,26 +168,27 @@
post "/scheduled_maintenances/#{entity_name_esc}/ping?"+
"start_time=1+day+ago&duration=30+minutes&summary=wow"
last_response.status.should == 302
end
- # FIXME: how to support the patch http method? ... also, is putting the post data into the url the
- # way to go here?
it "updates a scheduled maintenance period for an entity check" do
- t = Time.now.to_i
+ t = Time.new.to_i
start_time = t - (24 * 60 * 60)
Flapjack::Data::Entity.should_receive(:find_by_name).
with(entity_name, :redis => @redis).and_return(entity)
Flapjack::Data::EntityCheck.should_receive(:for_entity).
with(entity, 'ping', :redis => @redis).and_return(entity_check)
+ Chronic.should_receive(:parse).with('now').and_return(t)
+
entity_check.should_receive(:update_scheduled_maintenance).
with(start_time, {:end_time => t})
- patch "/scheduled_maintenances/#{entity_name_esc}/ping", {"start_time" => start_time, "end_time" => 'now'}
+ patch "/scheduled_maintenances/#{entity_name_esc}/ping",
+ {"start_time" => start_time, "end_time" => 'now'}
last_response.status.should == 302
end
it "deletes a scheduled maintenance period for an entity check" do
t = Time.now.to_i