Files
openfoodnetwork/spec/services/image_importer_spec.rb
David Cook c156d0c2e6 Add script to import product images from URL
With new ImageImporter.

Co-authored-by: Maikel <maikel@email.org.au>
2021-07-16 11:36:49 +10:00

22 lines
499 B
Ruby

# frozen_string_literal: false
require 'spec_helper'
describe ImageImporter do
let(:url) { Rails.root.join("spec/fixtures/files/logo.png").to_s }
let(:product) { create(:product) }
describe "#import" do
it "downloads and attaches to the product" do
expect {
subject.import(url, product)
}.to change {
Spree::Image.count
}.by(1)
expect(product.images.count).to eq 1
expect(product.images.first.attachment.size).to eq 6274
end
end
end