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.6.4 spec/feature/persisted_path_spec.rb
saviour-0.6.3 spec/feature/persisted_path_spec.rb
saviour-0.6.2 spec/feature/persisted_path_spec.rb
saviour-0.6.1 spec/feature/persisted_path_spec.rb
saviour-0.6.0 spec/feature/persisted_path_spec.rb
saviour-0.5.11 spec/feature/persisted_path_spec.rb
saviour-0.5.10 spec/feature/persisted_path_spec.rb
saviour-0.5.9 spec/feature/persisted_path_spec.rb
saviour-0.5.8 spec/feature/persisted_path_spec.rb
saviour-0.5.7 spec/feature/persisted_path_spec.rb
saviour-0.5.6 spec/feature/persisted_path_spec.rb
saviour-0.5.5 spec/feature/persisted_path_spec.rb
saviour-0.5.4 spec/feature/persisted_path_spec.rb
saviour-0.5.3 spec/feature/persisted_path_spec.rb
saviour-0.5.2 spec/feature/persisted_path_spec.rb
saviour-0.5.1 spec/feature/persisted_path_spec.rb
saviour-0.5.0 spec/feature/persisted_path_spec.rb
saviour-0.4.14 spec/feature/persisted_path_spec.rb
saviour-0.4.13 spec/feature/persisted_path_spec.rb
saviour-0.4.12 spec/feature/persisted_path_spec.rb