<commit_before>require 'spec_helper'

describe AccessPermission do
  it "has a valid factory" do
    expect(Factory.create(:access_permission)).to be_valid 
  end

  it "is invalid if an AccessPermission for that swarm and email already exists" do
    user = Factory.create(:user)
    swarm = Factory.create(:swarm)
    AccessPermission.create(:user => user, :swarm => swarm, :email => user.email)

    expect(AccessPermission.new(:user => user, :swarm => swarm, :email => user.email)).to_not be_valid
  end

  it "is invalid if an AccessPermission for that swarm and user already exists" do
    email = Faker::Internet.email
    swarm = Factory.create(:swarm)
    AccessPermission.create(:swarm => swarm, :email => email)

    expect(AccessPermission.new(:swarm => swarm, :email => email)).to_not be_valid
  end
end<commit_msg>If you're going to use Factories, use Factories.<commit_after>require 'spec_helper'

describe AccessPermission do
  it "has a valid factory" do
    expect(Factory.create(:access_permission)).to be_valid 
  end

  it "is invalid if an AccessPermission for that swarm and email already exists" do
    user = Factory.build(:user)
    swarm = Factory.build(:swarm)
    Factory.create(:access_permission, :user => user, :swarm => swarm, :email => user.email)

    expect(Factory.build(:access_permission, :user => user, :swarm => swarm, :email => user.email)).to_not be_valid
  end

  it "is invalid if an AccessPermission for that swarm and user already exists" do
    email = Faker::Internet.email
    swarm = Factory.create(:swarm)
    Factory.create(:access_permission, :email => email, :swarm => swarm, :user => nil)

    expect(Factory.build(:access_permission, :email => email, :swarm => swarm, :user => nil)).to_not be_valid
  end
end
{'fraction_non_alphanumeric': 0.11614730878186968, 'fraction_numerical': 0.0, 'mean_word_length': 4.335347432024169, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '2138065', 'n_tokens_mistral': 541, 'n_tokens_neox': 511, 'n_words': 164}