Files
ubicloud/spec/prog/check_usage_alerts_spec.rb
Jeremy Evans 4a41370c24 Remove all skip_if_frozen{_models} calls in the specs
There is no need for these calls now that all specs are run when
frozen.
2024-10-30 12:08:24 -07:00

21 lines
847 B
Ruby

# frozen_string_literal: true
require_relative "../model/spec_helper"
RSpec.describe Prog::CheckUsageAlerts do
subject(:cua) {
described_class.new(Strand.new(prog: "CheckUsageAlerts"))
}
describe "#wait" do
it "triggers alerts if usage is exceeded given threshold" do
exceeded = instance_double(UsageAlert, limit: 100, project: instance_double(Project, current_invoice: instance_double(Invoice, content: {"cost" => 1000})))
not_exceeded = instance_double(UsageAlert, limit: 100, project: instance_double(Project, current_invoice: instance_double(Invoice, content: {"cost" => 10})))
expect(UsageAlert).to receive(:where).and_return([exceeded, not_exceeded])
expect(exceeded).to receive(:trigger)
expect(not_exceeded).not_to receive(:trigger)
expect { cua.wait }.to nap(5 * 60)
end
end
end