Sha256: 8a7f71d20f784258e651ac286faa179ee1bb35f804551561be1177739b4433cb

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'
require 'shrine/plugins/kithe_storage_location'

describe Shrine::Plugins::KitheStorageLocation do
  let(:uploader) { test_uploader { plugin :kithe_storage_location } }

  it "uploads with a record with id" do
    uploaded_file = uploader.upload(fakeio, record: OpenStruct.new(id: "81060886-4f93-42e7-ace7-ab51399f4808"), name: :file)

    expect(uploaded_file.id).to match %r{\Aasset/81060886-4f93-42e7-ace7-ab51399f4808/[0-9a-f]+}
  end

  it "has suffix with a record id and filename" do
    uploaded_file = uploader.upload(fakeio(filename: "foo.jpg"), record: OpenStruct.new(id: "81060886-4f93-42e7-ace7-ab51399f4808"), name: :file)

    expect(uploaded_file.id).to match %r{\Aasset/81060886-4f93-42e7-ace7-ab51399f4808/[0-9a-f]+\.jpg}
  end

  it "uploads with no record" do
    uploaded_file = uploader.upload(fakeio, record: OpenStruct.new(id: "81060886-4f93-42e7-ace7-ab51399f4808"), name: :file)

    expect(uploaded_file.id).to match %r{\Aasset/[0-9a-f]+}
  end

  it "uploads with record with no id" do
    uploaded_file = uploader.upload(fakeio, record: OpenStruct.new(), name: :file)

    expect(uploaded_file.id).to match %r{\Aasset/[0-9a-f]+}
  end


end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kithe-2.0.0.pre.alpha2 spec/shrine/kithe_storage_location_spec.rb
kithe-2.0.0.pre.alpha1 spec/shrine/kithe_storage_location_spec.rb
kithe-1.1.2 spec/shrine/kithe_storage_location_spec.rb
kithe-1.1.1 spec/shrine/kithe_storage_location_spec.rb
kithe-1.1.0 spec/shrine/kithe_storage_location_spec.rb
kithe-1.0.0 spec/shrine/kithe_storage_location_spec.rb
kithe-0.3.0 spec/shrine/kithe_storage_location_spec.rb
kithe-0.2.0 spec/shrine/kithe_storage_location_spec.rb