Blinky tests?

pull/912/head
Rick Carlino 2018-07-16 09:51:31 -05:00
parent 5d5127ede3
commit 4cd6e39576
4 changed files with 11 additions and 4 deletions

View File

@ -79,11 +79,13 @@ class Device < ApplicationRecord
points.where(pointer_type: "Plant")
end
TIMEOUT = (Rails.env.test? ? 0.001 : 150).seconds
# Like Device.find, but with 150 seconds of caching to avoid DB calls.
def self.cached_find(id)
Rails
.cache
.fetch(CACHE_KEY % id, expires_in: 150.seconds) { Device.find(id) }
.fetch(CACHE_KEY % id, expires_in: TIMEOUT) { Device.find(id) }
end
def refresh_cache

View File

@ -57,8 +57,9 @@ describe Api::PinBindingsController do
end
it 'updates pin bindings' do
puts "Blinky test"
sign_in user
s = FakeSequence.create( device: device)
s = FakeSequence.create(device: device)
input = { pin_num: pin_binding.pin_num + 1, sequence_id: s.id}
put :update,
body: input.to_json,

View File

@ -10,8 +10,10 @@ describe LogService do
'"message":"HQ FarmBot TEST 123 Pin 13 is 0","created_at":'+
'1512585641,"channels":[]}'
FakeDeliveryInfo = Struct.new(:routing_key)
device_id = FactoryBot.create(:device).id
fake_delivery_info = FakeDeliveryInfo.new("bot.device_#{device_id}.logs")
let!(:device_id) { FactoryBot.create(:device).id }
let!(:fake_delivery_info) do
FakeDeliveryInfo.new("bot.device_#{device_id}.logs")
end
class FakeLogChan
attr_reader :subcribe_calls
@ -35,6 +37,7 @@ describe LogService do
end
it "creates new messages in the DB when called" do
puts "Blinky test"
Log.destroy_all
b4 = Log.count
LogService.process(fake_delivery_info, normal_payl)

View File

@ -18,6 +18,7 @@ end
describe "Pin Binding updates" do
it "enforces mutual exclusivity" do
puts "Blinky test"
PinBinding.destroy_all
Sequence.destroy_all
Device.destroy_all