<commit_before>require 'rails_helper'

describe QuotaEvent do
  let!(:quota_definition) { create :quota_definition }
  let!(:balance_event)    {
    create :quota_balance_event, quota_definition: quota_definition,
                                                         occurrence_timestamp: 3.days.ago
  }
  let!(:exhaustion_event) {
    create :quota_exhaustion_event, quota_definition: quota_definition,
                                                            occurrence_timestamp: 1.day.ago
  }
  let!(:critical_event) { create :quota_critical_event }

  describe '.for_quota_definition' do
    it 'returns all quota events for specified quota_definition_sid' do
      events = described_class.for_quota_definition(quota_definition.quota_definition_sid, Date.today).all
      expect(
        events.select { |ev| ev[:event_type] == "balance" }
      ).not_to be_blank
      expect(
        events.select { |ev| ev[:event_type] == "exhaustion" }<commit_msg>Fix intermittently-failing spec based on local timezone offset from UTC<commit_after>require 'rails_helper'

describe QuotaEvent do
  let!(:quota_definition) { create :quota_definition }
  let!(:balance_event)    {
    create :quota_balance_event, quota_definition: quota_definition,
                                                         occurrence_timestamp: 3.days.ago
  }
  let!(:exhaustion_event) {
    create :quota_exhaustion_event, quota_definition: quota_definition,
                                                            occurrence_timestamp: 25.hours.ago
  }
  let!(:critical_event) { create :quota_critical_event }

  describe '.for_quota_definition' do
    it 'returns all quota events for specified quota_definition_sid' do
      events = described_class.for_quota_definition(quota_definition.quota_definition_sid, Date.today).all
      expect(
        events.select { |ev| ev[:event_type] == "balance" }
      ).not_to be_blank
      expect(
        events.select { |ev| ev[:event_type] == "exhaustion" }
{'fraction_non_alphanumeric': 0.08689100954294325, 'fraction_numerical': 0.0025113008538422904, 'mean_word_length': 2.6685082872928176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7126755', 'n_tokens_mistral': 584, 'n_tokens_neox': 548, 'n_words': 113}