Sha256: c6bfb6706b04af800d3221fda918c83988e60f2685acd2b281f8648db79eecaa

Contents?: true

Size: 813 Bytes

Versions: 8

Compression:

Stored size: 813 Bytes

Contents

require 'spec_helper'

describe "direct usage of ReadOnlyFile" do
  before { allow(Saviour::Config).to receive(:storage).and_return(Saviour::LocalStorage.new(local_prefix: @tmpdir, public_url_prefix: "http://domain.com")) }

  let(:uploader) {
    Class.new(Saviour::BaseUploader) do
      store_dir { "/store/dir" }
    end
  }

  let(:klass) {
    klass = Class.new(Test) { include Saviour::Model }
    klass.attach_file :file, uploader
    klass
  }

  it "can be created" do
    a = klass.create! file: Saviour::StringSource.new("contents", "file.txt")

    path = a[:file]

    read_only_file = Saviour::ReadOnlyFile.new(path, klass.uploader_classes[:file].storage)

    expect(read_only_file.read).to eq "contents"
    expect(read_only_file.public_url).to eq "http://domain.com/store/dir/file.txt"
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
saviour-0.6.10 spec/feature/read_only_file_spec.rb
saviour-0.6.9 spec/feature/read_only_file_spec.rb
saviour-0.6.8 spec/feature/read_only_file_spec.rb
saviour-0.6.7 spec/feature/read_only_file_spec.rb
saviour-0.6.6 spec/feature/read_only_file_spec.rb
saviour-0.6.5 spec/feature/read_only_file_spec.rb
saviour-0.6.4 spec/feature/read_only_file_spec.rb
saviour-0.6.3 spec/feature/read_only_file_spec.rb