Sha256: 0df548fff1cb541d2c4d411bd2792a4593d98a89c8d0820f6dd6e6f82333f426

Contents?: true

Size: 1.26 KB

Versions: 33

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

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

  context "can change the default_path on the uploader and previous instances are not affected" do
    it do
      uploader = Class.new(Saviour::BaseUploader) { store_dir { "/store/dir" } }
      klass = Class.new(Test) { include Saviour::Model }
      klass.attach_file :file, uploader

      with_test_file("example.xml") do |example|
        a = klass.create!
        expect(a.update_attributes(file: example)).to be_truthy
        expect(Saviour::Config.storage.exists?(a[:file])).to be_truthy
        expect(File.dirname(a[:file])).to eq "/store/dir"


        uploader.class_eval { store_dir { "/another/dir" } }

        with_test_file("camaloon.jpg") do |example_2|
          b = klass.create!
          expect(b.update_attributes(file: example_2)).to be_truthy

          expect(Saviour::Config.storage.exists?(b[:file])).to be_truthy
          expect(Saviour::Config.storage.exists?(a[:file])).to be_truthy

          expect(File.dirname(b[:file])).to eq "/another/dir"
          expect(File.dirname(a[:file])).to eq "/store/dir"
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
saviour-0.4.11 spec/feature/persisted_path_spec.rb
saviour-0.4.10 spec/feature/persisted_path_spec.rb
saviour-0.4.9 spec/feature/persisted_path_spec.rb
saviour-0.4.8 spec/feature/persisted_path_spec.rb
saviour-0.4.7 spec/feature/persisted_path_spec.rb
saviour-0.4.6 spec/feature/persisted_path_spec.rb
saviour-0.4.5 spec/feature/persisted_path_spec.rb
saviour-0.4.4 spec/feature/persisted_path_spec.rb
saviour-0.4.3 spec/feature/persisted_path_spec.rb
saviour-0.4.2 spec/feature/persisted_path_spec.rb
saviour-0.4.1 spec/feature/persisted_path_spec.rb
saviour-0.4.0 spec/feature/persisted_path_spec.rb
saviour-0.3.1 spec/feature/persisted_path_spec.rb