<commit_before>require 'spec_helper'

describe Event do

  it 'should not replace without day' do
    Event.replace(nil, nil, nil).should be_nil
  end
  
  it 'should replace when giving a date and the record exists' do
    @event = FactoryGirl.create(:event)
    
    replacement = Event.replace(@event.day, nil, nil)
    
    replacement.should be_an_instance_of Event
    replacement.description.should be_nil
  end
  
  it 'should replace when giving a date and the record is new' do
    @event = FactoryGirl.build(:event)
    
    replacement = Event.replace(@event.day, nil, nil)
    <commit_msg>additional tests for Event<commit_after>require 'spec_helper'

describe Event do

  it 'has a valid factory' do
    FactoryGirl.build(:event).should be_valid
  end

  it 'is invalid without day' do
    FactoryGirl.build(:event, day: nil).should_not be_valid
  end
  
  it 'day should be unique' do
    FactoryGirl.create(:event)
    
    event = FactoryGirl.build(:event) # Same event
    event.should_not be_valid
    event.should have(1).error_on(:day)
  end
  
  it 'is invalid without activity' do
    FactoryGirl.build(:event, activity_id: nil).should_not be_valid
  end
  
  it 'is invalid without description' do
    FactoryGirl.build(:event, description: nil).should_not be_valid
  end
  
  it 'should not replace without day' do
    Event.replace(nil, nil, nil).should be_nil
  end
  
  it 'should replace when giving a date and the record exists' do
    @event = FactoryGirl.create(:event)
    
    replacement = Event.replace(@event.day, nil, nil)
    
    replacement.should be_an_instance_of Event
    replacement.description.should be_nil
  end
  
  it 'should replace when giving a date and the record is new' do
    @event = FactoryGirl.build(:event)
    
    replacement = Event.replace(@event.day, nil, nil)
    
{'fraction_non_alphanumeric': 0.08187772925764192, 'fraction_numerical': 0.0005458515283842794, 'mean_word_length': 3.2927400468384076, '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': '6406025', 'n_tokens_mistral': 567, 'n_tokens_neox': 558, 'n_words': 181}