<commit_before># frozen_string_literal: true

require 'rails_helper'

RSpec.describe Announcement, type: :model do
  describe '::deactivated' do
    it 'returns the right announcements' do
      a1 = create :announcement, deactivated_at: 1.week.ago
      a2 = create :announcement, deactivated_at: 1.week.since
      a3 = create :announcement, deactivated_at: nil

      expect(Announcement.deactivated).to include a1
      expect(Announcement.deactivated).not_to include a2, a3
    end
  end

  describe '::active' do
    it 'returns the right announcements' do
      a1 = create :announcement, deactivated_at: 1.week.ago
      a2 = create :announcement, deactivated_at: 1.week.since
      a3 = create :announcement, deactivated_at: nil

      expect(Announcement.active).not_to include a1
      expect(Announcement.active).to include a2, a3
    end
  end
<commit_msg>test: ensure announcements become inactive when scheduled<commit_after># frozen_string_literal: true

require 'rails_helper'

RSpec.describe Announcement, type: :model do
  describe '::deactivated' do
    it 'returns the right announcements' do
      a1 = create :announcement, deactivated_at: 1.week.ago
      a2 = create :announcement, deactivated_at: 1.week.since
      a3 = create :announcement, deactivated_at: nil

      expect(Announcement.deactivated).to include a1
      expect(Announcement.deactivated).not_to include a2, a3
    end
  end

  describe '::active' do
    it 'returns the right announcements' do
      a1 = create :announcement, deactivated_at: 1.week.ago
      a2 = create :announcement, deactivated_at: 1.week.since
      a3 = create :announcement, deactivated_at: nil

      expect(Announcement.active).to include a2, a3
      expect(Announcement.active).not_to include a1

      travel_to 2.weeks.since
      expect(Announcement.active).to include a3
      expect(Announcement.active).not_to include a1, a2
    end
  end

{'fraction_non_alphanumeric': 0.08242044861763172, 'fraction_numerical': 0.018779342723004695, 'mean_word_length': 3.5995203836930454, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1342821', 'n_tokens_mistral': 646, 'n_tokens_neox': 600, 'n_words': 167}