Skip to content

Commit

Permalink
misc(daily_usage): fix flacky test (#2772)
Browse files Browse the repository at this point in the history
## Description

This PR fixes a flacky test that was introduced by the recent
daily_usage feature

See #2718
  • Loading branch information
vincent-pochet authored Nov 4, 2024
1 parent f93c121 commit 3e1eb85
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions spec/services/daily_usages/compute_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@

describe '#call' do
it 'creates a daily usage', aggregate_failures: true do
expect { compute_service.call }.to change(DailyUsage, :count).by(1)

daily_usage = DailyUsage.order(created_at: :asc).last
expect(daily_usage).to have_attributes(
organization_id: organization.id,
customer_id: customer.id,
subscription_id: subscription.id,
external_subscription_id: subscription.external_id,
usage: Hash
)
expect(daily_usage.refreshed_at).to match_datetime(timestamp)
expect(daily_usage.from_datetime).to match_datetime(timestamp.beginning_of_month)
expect(daily_usage.to_datetime).to match_datetime(timestamp.end_of_month)
travel_to(timestamp) do
expect { compute_service.call }.to change(DailyUsage, :count).by(1)

daily_usage = DailyUsage.order(created_at: :asc).last
expect(daily_usage).to have_attributes(
organization_id: organization.id,
customer_id: customer.id,
subscription_id: subscription.id,
external_subscription_id: subscription.external_id,
usage: Hash
)
expect(daily_usage.refreshed_at).to match_datetime(timestamp)
expect(daily_usage.from_datetime).to match_datetime(timestamp.beginning_of_month)
expect(daily_usage.to_datetime).to match_datetime(timestamp.end_of_month)
end
end

context 'when a daily usage already exists' do
Expand Down

0 comments on commit 3e1eb85

Please sign in to comment.