<commit_before># == Schema Information
#
# Table name: holidays
#
#  id         :integer          not null, primary key
#  user_id    :integer
#  created_at :datetime         not null
#  updated_at :datetime         not null
#  start      :date
#  end        :date
#  status     :integer          default(0)
#

require 'rails_helper'

RSpec.describe Holiday, type: :model do
  before(:each) do
  	 @user = FactoryGirl.create(:user)
     #sign_in @user
     #@user.save!
  end

  it "has a valid factory" do
  	expect(FactoryGirl.create(:holiday, user_id: @user.id)).to be_valid
  end

  it "is invalid without a user" do
    expect(FactoryGirl.build(:holiday, user_id: nil)).to_not be_valid
  end

  it "is invalid when a wrong date is entered" do
    expect(FactoryGirl.build(:holiday, user_id: @user.id, start: Date.today-1, end: Date.today)).to_not be_valid
  end

  it "is invalid when end is before start" do
    expect(FactoryGirl.build(:holiday, user_id: @user.id, end: Date.yesterday)).to_not be_valid
  end

  it "is invalid when start is before today" do
  	expect(FactoryGirl.build(:holiday, user_id: @user.id, start: Date.yesterday)).to_not be_valid
  end

  it "is invalid when to far in the future" do
    expect(FactoryGirl.build(:holiday, user_id: @user.id, start: Date.new(Date.today.year + 2, 1, 1), end: Date.new(Date.today.year+2, 1, 2))).to_not be_valid
  end

  it "is invalid when not enough leave is left" do
    @user.update_attribute(:remaining_leave, 0)
    expect(FactoryGirl.build(:holiday, user_id: @user.id, start: Date.new(Date.today.year, 12, 31), end: Date.new(Date.today.year + 1, 1,1))).to_not be_valid
  end

  it "returns the duration" do
    holiday = FactoryGirl.create(:holiday, user_id: @user.id, start: Date.new(Date.today.year, 12, 31), end: Date.new(Date.today.year + 1, 1, 1))
    expect(holiday.duration).to eq(1)
  end
end
<commit_msg>fixed tests for holiday model<commit_after># == Schema Information
#
# Table name: holidays
#
#  id         :integer          not null, primary key
#  user_id    :integer
#  created_at :datetime         not null
#  updated_at :datetime         not null
#  start      :date
#  end        :date
#  status     :integer          default(0)
#

require 'rails_helper'

RSpec.describe Holiday, type: :model do
  before(:each) do
  	 @user = FactoryGirl.create(:user)
     #sign_in @user
     #@user.save!
  end

  it "has a valid factory" do
  	expect(FactoryGirl.create(:holiday, user_id: @user.id)).to be_valid
  end

  it "is invalid without a user" do
    expect(FactoryGirl.build(:holiday, user_id: nil)).to_not be_valid
  end

  it "is invalid when a wrong date is entered" do
    expect(FactoryGirl.build(:holiday, user_id: @user.id, start: Date.today-1, end: Date.today)).to_not be_valid
  end

  it "is invalid when end is before start" do
    expect(FactoryGirl.build(:holiday, user_id: @user.id, end: Date.yesterday)).to_not be_valid
  end

  it "is invalid when start is before today" do
  	expect(FactoryGirl.build(:holiday, user_id: @user.id, start: Date.yesterday)).to_not be_valid
  end

  it "is invalid when to far in the future" do
    expect(FactoryGirl.build(:holiday, user_id: @user.id, start: Date.new(Date.today.year + 2, 1, 1), end: Date.new(Date.today.year+2, 1, 2))).to_not be_valid
  end

  it "is invalid when not enough leave is left" do
    @user.update_attribute(:remaining_leave, 0)
    expect(FactoryGirl.build(:holiday, user_id: @user.id, start: Date.new(Date.today.year, 12, 20), end: Date.new(Date.today.year + 1, 1,1))).to_not be_valid
  end

  it "returns the duration" do
    holiday = FactoryGirl.create(:holiday, user_id: @user.id, start: Date.new(Date.today.year + 1, 12, 25), end: Date.new(Date.today.year + 1, 12, 26))
    expect(holiday.duration).to eq(0)
  end
end

{'fraction_non_alphanumeric': 0.12275607180570222, 'fraction_numerical': 0.013463569165786695, 'mean_word_length': 3.4419695193434934, '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': '2332433', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1308, 'n_words': 383}