<commit_before>require 'test_helper'

class AssignmentScopesTest < ActiveSupport::TestCase
  def setup
    @now = Time.zone.today
    make_assignment(title: 'starts_today_no_end', start_date: @now)
    make_assignment(title: 'started_60_days_ago_no_end', start_date: @now.days_ago(60))
    make_assignment(title: 'starts_in_one_month_no_end', start_date: @now.next_month.end_of_month)
    make_assignment(title: 'started_7_days_ago_ends_in_2_months', start_date: @now.days_ago(7),
      end_date: @now.next_month.next_month)
    make_assignment(title: 'started_60_days_ago_ended_30_days_ago', start_date: @now.days_ago(60),
      end_date: @now.days_ago(30))
    make_assignment(title: 'started_30_days_ago_ended_15_days_ago', start_date: @now.days_ago(30),
      end_date: @now.days_ago(15))
    make_assignment(title: 'starts_tomorrow_ends_next_month', start_date: @now.tomorrow,
      end_date: @now.next_month)
    make_assignment(title: 'started_yesterday_ends_tomorrow', start_date: @now.yesterday,
      end_date: @now.tomorrow)
    make_assignment(title: 'no_start_ends_today', end_date: @now)
    make_assignment(title: 'no_start_no_end')
  end

  test 'no_end returns only with no end date set' do
    query = Assignment.no_end
    assert query.include? @starts_today_no_end
    assert query.include? @started_60_days_ago_no_end
    assert query.include? @starts_in_one_month_no_end
    assert query.include? @no_start_no_end
    assert_equal 4, query.count
  end

  test 'has_end returns only with end date set' do
    query = Assignment.has_end
    assert query.include? @started_7_days_ago_ends_in_2_months
    assert query.include? @started_60_days_ago_ended_30_days_ago
    assert query.include? @started_30_days_ago_ended_15_days_ago
    assert query.include? @starts_tomorrow_ends_next_month
    assert query.include? @started_yesterday_ends_tomorrow
    assert query.include? @no_start_ends_today
    assert_equal 6, query.count
  end

  test 'end_in_past returns only with end_date in past or today' do
    query = Assignment.ended
    assert query.include? @started_60_days_ago_ended_30_days_ago
    assert query.include? @started_30_days_ago_ended_15_days_ago
    assert query.include? @no_start_ends_today
    assert_equal 3, query.count
  end

  test 'end_before returns only ended before parameter' do
    query = Assignment.end_before(@now)
    assert query.include? @started_60_days_ago_ended_30_days_ago
    assert query.include? @started_30_days_ago_ended_15_days_ago
    assert_equal 2, query.count
  end

  test 'end_after returns only ended after parameter' do
    query = Assignment.end_after(@now)
    assert query.include? @started_7_days_ago_ends_in_2_months
    assert query.include? @starts_tomorrow_ends_next_month<commit_msg>scope test should use the scope name<commit_after>require 'test_helper'

class AssignmentScopesTest < ActiveSupport::TestCase
  def setup
    @now = Time.zone.today
    make_assignment(title: 'starts_today_no_end', start_date: @now)
    make_assignment(title: 'started_60_days_ago_no_end', start_date: @now.days_ago(60))
    make_assignment(title: 'starts_in_one_month_no_end', start_date: @now.next_month.end_of_month)
    make_assignment(title: 'started_7_days_ago_ends_in_2_months', start_date: @now.days_ago(7),
      end_date: @now.next_month.next_month)
    make_assignment(title: 'started_60_days_ago_ended_30_days_ago', start_date: @now.days_ago(60),
      end_date: @now.days_ago(30))
    make_assignment(title: 'started_30_days_ago_ended_15_days_ago', start_date: @now.days_ago(30),
      end_date: @now.days_ago(15))
    make_assignment(title: 'starts_tomorrow_ends_next_month', start_date: @now.tomorrow,
      end_date: @now.next_month)
    make_assignment(title: 'started_yesterday_ends_tomorrow', start_date: @now.yesterday,
      end_date: @now.tomorrow)
    make_assignment(title: 'no_start_ends_today', end_date: @now)
    make_assignment(title: 'no_start_no_end')
  end

  test 'no_end returns only with no end date set' do
    query = Assignment.no_end
    assert query.include? @starts_today_no_end
    assert query.include? @started_60_days_ago_no_end
    assert query.include? @starts_in_one_month_no_end
    assert query.include? @no_start_no_end
    assert_equal 4, query.count
  end

  test 'has_end returns only with end date set' do
    query = Assignment.has_end
    assert query.include? @started_7_days_ago_ends_in_2_months
    assert query.include? @started_60_days_ago_ended_30_days_ago
    assert query.include? @started_30_days_ago_ended_15_days_ago
    assert query.include? @starts_tomorrow_ends_next_month
    assert query.include? @started_yesterday_ends_tomorrow
    assert query.include? @no_start_ends_today
    assert_equal 6, query.count
  end

  test 'ended returns only with end_date in past or today' do
    query = Assignment.ended
    assert query.include? @started_60_days_ago_ended_30_days_ago
    assert query.include? @started_30_days_ago_ended_15_days_ago
    assert query.include? @no_start_ends_today
    assert_equal 3, query.count
  end

  test 'end_before returns only ended before parameter' do
    query = Assignment.end_before(@now)
    assert query.include? @started_60_days_ago_ended_30_days_ago
    assert query.include? @started_30_days_ago_ended_15_days_ago
    assert_equal 2, query.count
  end

  test 'end_after returns only ended after parameter' do
    query = Assignment.end_after(@now)
    assert query.include? @started_7_days_ago_ends_in_2_months
    assert query.include? @starts_tomorrow_ends_next_month
{'fraction_non_alphanumeric': 0.0775473399458972, 'fraction_numerical': 0.02055906221821461, 'mean_word_length': 5.323831242873432, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1351469', 'n_tokens_mistral': 2050, 'n_tokens_neox': 1936, 'n_words': 367}