<commit_before>require "spec_helper"

describe Spree::Marketing::List, type: :model do

  let(:active_list) { create(:marketing_list, active: true) }
  let(:inactive_list) { create(:marketing_list, active: false) }

  describe "Validations" do
    it { is_expected.to validate_presence_of(:uid) }
    it { is_expected.to validate_presence_of(:name) }
    #Spec would fail without subject assignment at db level
    context "validates uniqueness of" do
      subject { create(:marketing_list) }
      it { is_expected.to validate_uniqueness_of(:uid).case_insensitive }
    end
  end

  describe "Associations" do
    it { is_expected.to have_many(:contacts_lists).class_name("Spree::Marketing::ContactsList").dependent(:destroy) }
    it { is_expected.to have_many(:contacts).through(:contacts_lists) }
  end

  describe "Scopes" do
    context ".active" do
      it { expect(Spree::Marketing::List.active).to include active_list }
      it { expect(Spree::Marketing::List.active).to_not include inactive_list }
    end
  end

  describe "#user_ids" do
    it { expect {active_list.user_ids}.to raise_error(::NotImplementedError) }
  end

  describe "#generate" do
    let!(:list_name) { 'test' }

    before do<commit_msg>Add constant specs to list<commit_after>require "spec_helper"

describe Spree::Marketing::List, type: :model do

  let(:active_list) { create(:marketing_list, active: true) }
  let(:inactive_list) { create(:marketing_list, active: false) }

  describe "Constants" do
    it { expect(Spree::Marketing::List::TIME_FRAME).to eq(1.week) }
  end

  describe "Validations" do
    it { is_expected.to validate_presence_of(:uid) }
    it { is_expected.to validate_presence_of(:name) }
    #Spec would fail without subject assignment at db level
    context "validates uniqueness of" do
      subject { create(:marketing_list) }
      it { is_expected.to validate_uniqueness_of(:uid).case_insensitive }
    end
  end

  describe "Associations" do
    it { is_expected.to have_many(:contacts_lists).class_name("Spree::Marketing::ContactsList").dependent(:destroy) }
    it { is_expected.to have_many(:contacts).through(:contacts_lists) }
  end

  describe "Scopes" do
    context ".active" do
      it { expect(Spree::Marketing::List.active).to include active_list }
      it { expect(Spree::Marketing::List.active).to_not include inactive_list }
    end
  end

  describe "#user_ids" do
    it { expect {active_list.user_ids}.to raise_error(::NotImplementedError) }
  end

  describe "#generate" do
    let!(:list_name) { 'test' }

    before do
{'fraction_non_alphanumeric': 0.1164972634870993, 'fraction_numerical': 0.00039093041438623924, 'mean_word_length': 4.3423799582463465, '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': '5616017', 'n_tokens_mistral': 833, 'n_tokens_neox': 810, 'n_words': 182}