<commit_before># encoding: UTF-8
require 'require_relative' if RUBY_VERSION[0,3] == '1.8'
require_relative '../test_helper'

describe User do

  include TestHelper

  describe "#at_replies" do
    it "returns all at_replies for this user" do
      skip "carol broke this test somehow-- undefined method `length' for Plucky::Query"
      u = User.create(:username => "steve")
      update = Update.create(:text => "@steve oh hai!")
      Update.create(:text => "just some other update")

      assert_equal 1, u.at_replies({}).length
      assert_equal update.id, u.at_replies({}).first.id
    end

    it "returns all at_replies for a username containing ." do
      skip "carol broke this test somehow-- undefined method `length' for Plucky::Query"
      u = Factory.create(:user, :username => "hello.there")
      u1 = Factory.create(:user, :username => "helloothere")
      update = Update.create(:text => "@hello.there how _you_ doin'?")

      assert_equal 1, u.at_replies({}).length
      assert_equal 0, u1.at_replies({}).length
    end
  end

  describe "username" do
    it "must be unique" do
      Factory(:user, :username => "steve")
      u = Factory.build(:user, :username => "steve")
      refute u.save
    end

    it "must be unique regardless of case" do
      Factory(:user, :username => "steve")
      u = Factory.build(:user, :username => "Steve")
      refute u.save
    end

    it "must not be long" do<commit_msg>bad carol, bad merge. plucky query has to use .count, not .length, and commit 762b8a1 had already fixed this then I unfixed it.<commit_after># encoding: UTF-8
require 'require_relative' if RUBY_VERSION[0,3] == '1.8'
require_relative '../test_helper'

describe User do

  include TestHelper

  describe "#at_replies" do
    it "returns all at_replies for this user" do
      u = User.create(:username => "steve")
      update = Update.create(:text => "@steve oh hai!")
      Update.create(:text => "just some other update")

      assert_equal 1, u.at_replies({}).count
      assert_equal update.id, u.at_replies({}).first.id
    end

    it "returns all at_replies for a username containing ." do
      u = Factory.create(:user, :username => "hello.there")
      u1 = Factory.create(:user, :username => "helloothere")
      update = Update.create(:text => "@hello.there how _you_ doin'?")

      assert_equal 1, u.at_replies({}).count
      assert_equal 0, u1.at_replies({}).count
    end
  end

  describe "username" do
    it "must be unique" do
      Factory(:user, :username => "steve")
      u = Factory.build(:user, :username => "steve")
      refute u.save
    end

    it "must be unique regardless of case" do
      Factory(:user, :username => "steve")
      u = Factory.build(:user, :username => "Steve")
      refute u.save
    end

    it "must not be long" do
{'fraction_non_alphanumeric': 0.13127001067235858, 'fraction_numerical': 0.008893632159373888, 'mean_word_length': 3.057720057720058, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '3357918', 'n_tokens_mistral': 909, 'n_tokens_neox': 888, 'n_words': 281}