<commit_before>require 'rails_helper'

RSpec.describe Reservation do
  describe 'validations' do
    it { is_expected.to validate_presence_of :user }
    it { is_expected.to validate_presence_of :schedule_item }

    context 'with schedule item starting in the past' do
      subject { build(:reservation, schedule_item: build(:schedule_item, start: DateTime.now - 1.day ))}
      it 'is invalid' do
        is_expected.to be_invalid
        expect(subject.errors[:schedule_item]).to include('can\'t make reservations for items from the past')
      end
    end
  end
end<commit_msg>Add checking for full schedule items to specs<commit_after>require 'rails_helper'

RSpec.describe Reservation do
  describe 'validations' do
    it { is_expected.to validate_presence_of :user }
    it { is_expected.to validate_presence_of :schedule_item }

    context 'with schedule item starting in the past' do
      subject { build(:reservation, schedule_item: build(:schedule_item, start: DateTime.now - 1.day ))}

      it 'is invalid' do
        is_expected.to be_invalid
        expect(subject.errors[:schedule_item]).to include('can\'t make reservations for items from the past')
      end
    end

    context 'with schedule_items that can\'t accept any more users' do
      before :each do
        @full_schedule_item = create(:schedule_item, capacity: 1)
        create(:reservation, schedule_item: @full_schedule_item)
      end

      subject { build(:reservation, schedule_item: @full_schedule_item) }
      it 'is invalid' do
        is_expected.to be_invalid
        expect(subject.errors[:schedule_item]).to include('schedule_item capacity exceeded')
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.0821917808219178, 'fraction_numerical': 0.001786777843954735, 'mean_word_length': 3.5283018867924527, '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': '3374534', 'n_tokens_mistral': 488, 'n_tokens_neox': 471, 'n_words': 145}