<commit_before>require 'spec_helper'

describe ::Trax::Model::Attributes::Types::Array, :postgres => true do
  subject{ ::Ecommerce::Vote.new(:upvoter_ids_array => ["1", "2"], :downvoter_ids_array => ["3", "4", "5"] )}

  it { expect(subject.upvoter_ids_array.__getobj__).to be_a(::Array) }
  it { expect(subject.upvoter_ids_array).to include("1") }

  context "attribute definition" do
    subject { ::Ecommerce::Vote::Fields::UpvoterIdsArray.new }
    it { expect(subject.__getobj__).to be_a(::Array) }
  end

  context "loading from database" do
    it {
      subject.save
      test_subject = subject.reload
      expect(test_subject.upvoter_ids_array).to include("1")
    }
  end

  context "does allow duplicate values" do
    it {
      subject.upvoter_ids_array << "1"
      expect(subject.upvoter_ids_array.length).to eq 3
    }
  end

  context "dirty tracking" do
    it {
      subject.save
      subject.upvoter_ids_array = ["2","3"]
      expect(subject.upvoter_ids_array_was).to eq ::Array.new(["1","2"])
    }
  end

  context "setting value" do
    context "already an array" do
      let(:val) { ::Ecommerce::Vote::Fields::UpvoterIdsArray.new(["1", "2"]) }<commit_msg>additional spec for upvoters id array<commit_after>require 'spec_helper'

describe ::Trax::Model::Attributes::Types::Array, :postgres => true do
  subject{ ::Ecommerce::Vote.new(:upvoter_ids_array => ["1", "2"], :downvoter_ids_array => ["3", "4", "5"] )}

  it { expect(subject.upvoter_ids_array.__getobj__).to be_a(::Array) }
  it { expect(subject.upvoter_ids_array).to include("1") }

  context "attribute definition" do
    subject { ::Ecommerce::Vote::Fields::UpvoterIdsArray.new }
    it { expect(subject.__getobj__).to be_a(::Array) }
  end

  context "loading from database" do
    it {
      subject.save
      test_subject = subject.reload
      expect(test_subject.upvoter_ids_array).to include("1")
    }
  end

  context "does allow duplicate values" do
    it {
      subject.upvoter_ids_array << "1"
      expect(subject.upvoter_ids_array.length).to eq 3
      expect(subject.upvoter_ids_array.select{|v| v == "1"}.length).to eq 2
    }
  end

  context "dirty tracking" do
    it {
      subject.save
      subject.upvoter_ids_array = ["2","3"]
      expect(subject.upvoter_ids_array_was).to eq ::Array.new(["1","2"])
    }
  end

  context "setting value" do
    context "already an array" do
      let(:val) { ::Ecommerce::Vote::Fields::UpvoterIdsArray.new(["1", "2"]) }
{'fraction_non_alphanumeric': 0.15278900565885206, 'fraction_numerical': 0.012934518997574777, 'mean_word_length': 3.815175097276265, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '4250954', 'n_tokens_mistral': 879, 'n_tokens_neox': 856, 'n_words': 170}