Sha256: 258b6a85c58f6eb6ba8e5b9ea31fe4a33da6e52d4eee11ea9da0b8d85acafd32

Contents?: true

Size: 1.13 KB

Versions: 27

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe "halt processor behavior" 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" }
      process { |_contents, _name| halt_process }
    end
  }

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

  it "does not write the file" do
    a = klass.create!

    expect(Saviour::Config.storage).to_not receive(:write)

    a.update_attributes! file: StringIO.new("contents")
    expect(a.reload.read_attribute(:file)).to be_nil
  end

  it "is considered as not persisted after save" do
    a = klass.new
    a.file = StringIO.new("contents")
    expect(a.file.persisted?).to be_falsey
    a.save
    expect(a.file.persisted?).to be_falsey
  end

  it "is considered as not dirty after save" do
    a = klass.new
    a.file = StringIO.new("contents")
    expect(a.file.changed?).to be_truthy
    a.save
    expect(a.file.changed?).to be_falsey
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
saviour-0.6.4 spec/feature/halt_processor_spec.rb
saviour-0.6.3 spec/feature/halt_processor_spec.rb
saviour-0.6.2 spec/feature/halt_processor_spec.rb
saviour-0.6.1 spec/feature/halt_processor_spec.rb
saviour-0.6.0 spec/feature/halt_processor_spec.rb
saviour-0.5.11 spec/feature/halt_processor_spec.rb
saviour-0.5.10 spec/feature/halt_processor_spec.rb
saviour-0.5.9 spec/feature/halt_processor_spec.rb
saviour-0.5.8 spec/feature/halt_processor_spec.rb
saviour-0.5.7 spec/feature/halt_processor_spec.rb
saviour-0.5.6 spec/feature/halt_processor_spec.rb
saviour-0.5.5 spec/feature/halt_processor_spec.rb
saviour-0.5.4 spec/feature/halt_processor_spec.rb
saviour-0.5.3 spec/feature/halt_processor_spec.rb
saviour-0.5.2 spec/feature/halt_processor_spec.rb
saviour-0.5.1 spec/feature/halt_processor_spec.rb
saviour-0.5.0 spec/feature/halt_processor_spec.rb
saviour-0.4.14 spec/feature/halt_processor_spec.rb
saviour-0.4.13 spec/feature/halt_processor_spec.rb
saviour-0.4.12 spec/feature/halt_processor_spec.rb