Skip to content

Commit

Permalink
aded rspec covering scheduling chargeback generation for not retiered…
Browse files Browse the repository at this point in the history
… servcie in the same region
  • Loading branch information
yrudman committed Aug 8, 2019
1 parent 4622cf5 commit b510356
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion spec/models/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -425,15 +425,30 @@
end

describe ".queue_chargeback_reports" do
it "queue request to generate chargeback report for each service" do
before do
@service_c1 = FactoryBot.create(:service, :service => @service)
@service_c1.name = "Test_Service_2"
@service_c1 << @vm1
@service_c1.save
end

it "queue request to generate chargeback report for each service" do
expect(MiqQueue).to receive(:put).twice
described_class.queue_chargeback_reports
end

it "queue request to generate chargeback report only in service's region" do
allow(Service).to receive(:in_my_region).and_return([@service_c1])
expect(MiqQueue).to receive(:put).once
described_class.queue_chargeback_reports
end

it "does not queue request to generate chargeback report if service retired" do
@service_c1.update(:retired => true)
allow(Service).to receive(:in_my_region).and_return([@service_c1])
expect(MiqQueue).not_to receive(:put)
described_class.queue_chargeback_reports
end
end

describe "#chargeback_report_name" do
Expand Down

0 comments on commit b510356

Please sign in to comment.