<commit_before>require "rails_helper"

RSpec.describe Submission, type: :model do
  it "has a valid factory" do
    expect(FactoryGirl.build(:submission)).to be_valid
  end

  it "requires a full_name" do
    expect(FactoryGirl.build(:submission, full_name: "")).not_to be_valid
  end

  it "requires a valid email" do
    expect(FactoryGirl.build(:submission, email: "invalid#email.io")).not_to be_valid
    expect(FactoryGirl.build(:submission, email: "<EMAIL>")).not_to be_valid
  end

  it "requires age between 0 and 110" do
    expect(FactoryGirl.build(:submission, age: -30)).not_to be_valid
    expect(FactoryGirl.build(:submission, age: 130)).not_to be_valid
  end

  context "scopes" do
    before(:all) do
      @rejected_submission = FactoryGirl.create(:submission, rejected: true)
      @to_rate_submission = FactoryGirl.create(:submission)
      @rated_submission = FactoryGirl.create(:submission, :with_rates)
    end

    it "should only return rejected submissions" do
      expect(Submission.rejected).to eq [@rejected_submission]
    end

    it "should only return submissions to rate" do
      expect(Submission.to_rate).to eq [@to_rate_submission]
    end

    it "should only return rated submissions" do
      expect(Submission.rated).to eq [@rated_submission]
    end

  end
end<commit_msg>Improve submission model spec<commit_after>require "rails_helper"

RSpec.describe Submission, type: :model do
  it "has a valid factory" do
    expect(FactoryGirl.build(:submission)).to be_valid
  end

  it "requires a full_name" do
    expect(FactoryGirl.build(:submission, full_name: "")).not_to be_valid
  end

  it "requires a valid email" do
    expect(FactoryGirl.build(:submission, email: "invalid#email.io")).not_to be_valid
    expect(FactoryGirl.build(:submission, email: "<EMAIL>")).not_to be_valid
  end

  it "requires age between 0 and 110" do
    expect(FactoryGirl.build(:submission, age: -30)).not_to be_valid
    expect(FactoryGirl.build(:submission, age: 130)).not_to be_valid
  end

  context "scopes" do
    let!(:rejected_submission) { FactoryGirl.create(:submission, rejected: true) }
    let!(:to_rate_submission) { FactoryGirl.create(:submission) }
    let!(:rated_submission) { FactoryGirl.create(:submission, :with_rates) }

    it "should only return rejected submissions" do
      expect(Submission.rejected).to eq [rejected_submission]
    end

    it "should only return submissions to rate" do
      expect(Submission.to_rate).to eq [to_rate_submission]
    end

    it "should only return rated submissions" do
      expect(Submission.rated).to eq [rated_submission]
    end
  end
end
{'fraction_non_alphanumeric': 0.10410334346504559, 'fraction_numerical': 0.006838905775075988, 'mean_word_length': 4.2554890219560875, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6597446', 'n_tokens_mistral': 886, 'n_tokens_neox': 816, 'n_words': 217}