<commit_before>require "spec_helper"

describe Uploader do
  let(:path) { "spec/fixtures/files/photos/" }
  let(:full_path) { File.expand_path(path) }
  let(:filename) { "P1120375.JPG" }
  let(:filepath) { File.join(path, filename) }
  let(:title) { "New Album" }
  let(:album_photos) { double(:album_photos, keys: [], create: nil) }
  subject(:uploader) { Uploader.new(title) }

  before do
    allow(AlbumPhotos).to receive(:new).with(title) { album_photos }
  end

  describe "#upload" do
    it "uploads the file" do
      uploader.upload(path, filename, :web)
      expect(album_photos).to have_received(:create)
        .with(filename, File.join(full_path, filename), type: :web)
    end

    it "raises for invalid types" do
      expect {
        uploader.upload(path, filename, :foo)
      }.to raise_error
    end
  end

  describe "#upload_all" do
    it "uploads all files" do
      uploader.upload_all(path, :web)
      expect(album_photos).to have_received(:create).once
        .with(filename, File.join(full_path, filename), type: :web)
    end

    it "skips existing_photos" do
      allow(album_photos).to receive(:keys).with(:web) { [filename] }
      uploader.upload_all(path, :web)
      expect(album_photos).not_to have_received(:create)
    end

    it "raises for invalid types" do
      expect {
        uploader.upload_all(:foo)
      }.to raise_error
    end
  end
end<commit_msg>Fix warning and bad test case<commit_after>require "spec_helper"

describe Uploader do
  let(:path) { "spec/fixtures/files/photos/" }
  let(:full_path) { File.expand_path(path) }
  let(:filename) { "P1120375.JPG" }
  let(:filepath) { File.join(path, filename) }
  let(:title) { "New Album" }
  let(:album_photos) { double(:album_photos, keys: [], create: nil) }
  subject(:uploader) { Uploader.new(title) }

  before do
    allow(AlbumPhotos).to receive(:new).with(title) { album_photos }
  end

  describe "#upload" do
    it "uploads the file" do
      uploader.upload(path, filename, :web)
      expect(album_photos).to have_received(:create)
        .with(filename, File.join(full_path, filename), type: :web)
    end

    it "raises for invalid types" do
      expect {
        uploader.upload(path, filename, :foo)
      }.to raise_error 'invalid type'
    end
  end

  describe "#upload_all" do
    it "uploads all files" do
      uploader.upload_all(path, :web)
      expect(album_photos).to have_received(:create).once
        .with(filename, File.join(full_path, filename), type: :web)
    end

    it "skips existing_photos" do
      allow(album_photos).to receive(:keys).with(:web) { [filename] }
      uploader.upload_all(path, :web)
      expect(album_photos).not_to have_received(:create)
    end

    it "raises for invalid types" do
      expect {
        uploader.upload_all(path, :foo)
      }.to raise_error 'invalid type'
    end
  end
end
{'fraction_non_alphanumeric': 0.1300557880055788, 'fraction_numerical': 0.0048814504881450485, 'mean_word_length': 3.3013493253373314, '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': '7642659', 'n_tokens_mistral': 1003, 'n_tokens_neox': 944, 'n_words': 221}