Sha256: e0866ec6c274908df19c9852a3bcef7bab6d91852e52ce81bc70adcf49ef7ff7

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'
require 'shrine/plugins/kithe_multi_cache'
require 'webmock/rspec'

describe Shrine::Plugins::KitheMultiCache do
  let(:extra_storage) { Shrine::Storage::Memory.new }

  let(:attacher) do
    s = extra_storage
    test_attacher! do
      storages[:additional_one] = s
      plugin :kithe_multi_cache, additional_cache: :additional_one
    end
  end

  it "can assign from additional cache" do
    attacher.assign({"id" => "test_id", "storage" => "additional_one"}.to_json)
    expect(attacher.get).not_to be_nil
    expect(attacher.get.data).to include({"id" => "test_id", "storage" => "additional_one"})
  end

  it "can promote from additional cache" do
    extra_storage.upload(fakeio("test_content"), "test_id")
    attacher.assign({"id" => "test_id", "storage" => "additional_one"}.to_json)
    attacher.promote

    uploaded_file = attacher.get
    expect(uploaded_file).not_to be_nil
    expect(uploaded_file.data["storage"]).to eq(attacher.store.storage_key.to_s)
    expect(uploaded_file.data["id"]).not_to be_nil
    expect(uploaded_file.read).to eq("test_content")
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kithe-2.0.2 spec/shrine/kithe_multi_cache_spec.rb
kithe-2.0.1 spec/shrine/kithe_multi_cache_spec.rb
kithe-2.0.0 spec/shrine/kithe_multi_cache_spec.rb
kithe-2.0.0.pre.rc1 spec/shrine/kithe_multi_cache_spec.rb
kithe-2.0.0.pre.beta1 spec/shrine/kithe_multi_cache_spec.rb
kithe-2.0.0.pre.alpha2 spec/shrine/kithe_multi_cache_spec.rb
kithe-2.0.0.pre.alpha1 spec/shrine/kithe_multi_cache_spec.rb