<commit_before>require File.expand_path('../../../spec_helper', __FILE__)

describe Portal::Student do
  before(:each) do
    @student = Factory(:portal_student)
  end
  
  describe "when a clazz is added to a students list of clazzes" do
    it "the students clazz list increases by one if the student is not already enrolled in that class" do
      clazz = Factory(:portal_clazz)
      @student.clazzes.should be_empty
      @student.add_clazz(clazz)
      @student.reload
      @student.clazzes.should_not be_empty
      @student.clazzes.should include(clazz)
      @student.should have(1).clazzes
    end
    
    it "the students clazz list should stay the same if the same clazz is added multiple times" do
      clazz = Factory(:portal_clazz)
      @student.clazzes.should be_empty
      @student.add_clazz(clazz)
      @student.add_clazz(clazz)
      @student.reload
      @student.clazzes.should_not be_empty
      @student.clazzes.should include(clazz)
      @student.should have(1).clazzes
    end
  end
  
  it "should generate a user name by first initial and last name" do
    Portal::Student.generate_user_login("test", "user").should == "tuser"
    
    first_name = "Nametest"
    last_name  = "Testuser"
    @student.user = Factory.create(:user, {
      :first_name => first_name,
      :last_name => last_name,
      :login => Portal::Student.generate_user_login(first_name, last_name),
      :password => "password",
      :password_confirmation => "password",
      :email => "<EMAIL>"
    })
    @student.user.login.should == "ntestuser"
    Portal::Student.generate_user_login(@student.first_name, @student.last_name).should == @student.user.login + "2"
  end

end<commit_msg>fix failing login generation spec<commit_after>require File.expand_path('../../../spec_helper', __FILE__)

describe Portal::Student do
  before(:each) do
    @student = Factory(:portal_student)
  end
  
  describe "when a clazz is added to a students list of clazzes" do
    it "the students clazz list increases by one if the student is not already enrolled in that class" do
      clazz = Factory(:portal_clazz)
      @student.clazzes.should be_empty
      @student.add_clazz(clazz)
      @student.reload
      @student.clazzes.should_not be_empty
      @student.clazzes.should include(clazz)
      @student.should have(1).clazzes
    end
    
    it "the students clazz list should stay the same if the same clazz is added multiple times" do
      clazz = Factory(:portal_clazz)
      @student.clazzes.should be_empty
      @student.add_clazz(clazz)
      @student.add_clazz(clazz)
      @student.reload
      @student.clazzes.should_not be_empty
      @student.clazzes.should include(clazz)
      @student.should have(1).clazzes
    end
  end
  
  it "should generate a user name by first initial and last name" do
    Portal::Student.generate_user_login("test", "user").should == "tuser"
    
    first_name = "Nametest"
    last_name  = "Testuser"
    @student.user = Factory.create(:user, {
      :first_name => first_name,
      :last_name => last_name,
      :login => Portal::Student.generate_user_login(first_name, last_name),
      :password => "password",
      :password_confirmation => "password",
      :email => "<EMAIL>"
    })
    @student.user.login.should == "ntestuser"
    Portal::Student.generate_user_login(@student.first_name, @student.last_name).should == @student.user.login + "1"
  end

end
{'fraction_non_alphanumeric': 0.10942071386775892, 'fraction_numerical': 0.0017554125219426564, 'mean_word_length': 3.2577833125778333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '1538446', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1086, 'n_words': 267}