Merge branch 'master' of github.com:openfoodfoundation/openfoodnetwork into state_translation_override

Conflicts:
	spec/lib/open_food_network/order_cycle_management_report_spec.rb
This commit is contained in:
Maikel Linke
2016-04-15 08:27:09 +10:00
9 changed files with 155 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
require 'spec_helper'
module Api
describe StatusesController do
render_views
describe "job queue status" do
it "returns alive when up to date" do
Spree::Config.last_job_queue_heartbeat_at = Time.now
spree_get :job_queue
response.should be_success
response.body.should == {alive: true}.to_json
end
it "returns dead otherwise" do
Spree::Config.last_job_queue_heartbeat_at = 10.minutes.ago
spree_get :job_queue
response.should be_success
response.body.should == {alive: false}.to_json
end
it "returns dead when no heartbeat recorded" do
Spree::Config.last_job_queue_heartbeat_at = nil
spree_get :job_queue
response.should be_success
response.body.should == {alive: false}.to_json
end
end
end
end

View File

@@ -0,0 +1,27 @@
require 'spec_helper'
describe HeartbeatJob do
context "with time frozen" do
let(:run_time) { Time.zone.local(2016, 4, 13, 13, 0, 0) }
before { Spree::Config.last_job_queue_heartbeat_at = nil }
around do |example|
Timecop.freeze(run_time) { example.run }
end
it "updates the last_job_queue_heartbeat_at config var" do
run_job
Time.parse(Spree::Config.last_job_queue_heartbeat_at).should == run_time
end
end
private
def run_job
clear_jobs
Delayed::Job.enqueue HeartbeatJob.new
flush_jobs ignore_exceptions: false
end
end

View File

@@ -92,7 +92,7 @@ module OpenFoodNetwork
# payment2 = create(:payment, order: order2, payment_method: pm2)
subject.stub(:params).and_return(payment_method_in: [pm1.id, pm3.id] )
subject.filter(orders).should == [order1, order3]
subject.filter(orders).should match_array [order1, order3]
end
it "filters to a shipping method" do