Sha256: e13025189c18c52328517f6daec8cca18765b18563678f4aca4c9d69ff9895b8

Contents?: true

Size: 924 Bytes

Versions: 5

Compression:

Stored size: 924 Bytes

Contents

require 'spec_helper'

describe "access to model data from uploaders" 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/#{model.id}" }
      process { |contents, name| [contents, "#{model.id}-#{attached_as}-#{name}"] }
    end
  }

  let(:klass) {
    klass = Class.new(Test) {
      include Saviour::Model

      def id
        87
      end
    }
    klass.attach_file :file, uploader
    klass
  }

  describe "file store" do
    it do
      with_test_file("example.xml") do |example, name|
        a = klass.new
        a.file = example
        path = a.file.write

        expect(Saviour::Config.storage.exists?(path)).to be_truthy
        expect(path).to eq "/store/dir/87/87-file-#{name}"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
saviour-0.4.3 spec/feature/access_to_model_and_mounted_as_spec.rb
saviour-0.4.2 spec/feature/access_to_model_and_mounted_as_spec.rb
saviour-0.4.1 spec/feature/access_to_model_and_mounted_as_spec.rb
saviour-0.4.0 spec/feature/access_to_model_and_mounted_as_spec.rb
saviour-0.3.1 spec/feature/access_to_model_and_mounted_as_spec.rb