saviour 0.4.8 → 0.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 709681c9a25bc91c834cdf0d2ad1027fbd64a458
4
- data.tar.gz: 21ba25beeb98a5aa4ff061f96143896ec7006d5a
3
+ metadata.gz: 52d3e1c76ad21adf351834a7d0dd101582e9a835
4
+ data.tar.gz: 2ac25be01722c1432e8f75408be8a448b0505761
5
5
  SHA512:
6
- metadata.gz: 4e2f3746a2455e442ae5920f65244eb8ba596ca6a77864e30d4bb24a388ee14fb2bf17c806112071f7c80310bcaee3fb05077484fb1bd97fd83ca6d2a2b95f0d
7
- data.tar.gz: db8b60ee46c478b21faa237ed688c5a53a8526e022df2962cd8ad162948322ae3aa6c6850af5876d7c5fe4dcb01fe5f442559137a84e8f713bd5927a901b72fa
6
+ metadata.gz: ace50b4dfc8bfc04ab889fcbf92955d0815eb9f48fa97900ca3f9227d80deabba9f8e74e79f1ee4258f288058268d34faeab0f0563e3ece363c868e53d637195
7
+ data.tar.gz: b7b9b71f3150a8142a84ddcf9979ba3be6cea056692d42f580e2496db2525103368ceb158e9fadba150292103573998e82488ba0ca29af654efabfaed3273da9
@@ -55,7 +55,7 @@ module Saviour
55
55
  self.filename = result[1]
56
56
 
57
57
  else
58
- file.rewind
58
+ file.reopen(file.path)
59
59
 
60
60
  result = run_method_or_block(method_or_block, opts, file)
61
61
 
@@ -1,3 +1,3 @@
1
1
  module Saviour
2
- VERSION = "0.4.8"
2
+ VERSION = "0.4.9"
3
3
  end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe "file information" do
4
+ before { allow(Saviour::Config).to receive(:storage).and_return(Saviour::LocalStorage.new(local_prefix: @tmpdir, public_url_prefix: "http://domain.com")) }
5
+
6
+ let(:uploader) {
7
+ Class.new(Saviour::BaseUploader) do
8
+ store_dir { "/store/dir/#{model.id}" }
9
+ process_with_file do |file, name|
10
+ model.result1 = file.stat.size
11
+
12
+ path = file.path
13
+
14
+ # Assign new contents on the same path, forcing a new inode
15
+ ::File.delete(path)
16
+ ::File.write(path, "SOME NEW DATA, LONGER")
17
+
18
+ [file, name]
19
+ end
20
+
21
+ process_with_file do |file, name|
22
+ model.result2 = file.stat.size # This must be the size of the new contents
23
+
24
+ [file, name]
25
+ end
26
+ end
27
+ }
28
+
29
+ let(:klass) {
30
+ klass = Class.new(Test) {
31
+ attr_accessor :result1, :result2
32
+ include Saviour::Model
33
+ }
34
+ klass.attach_file :file, uploader
35
+ klass
36
+ }
37
+
38
+ it "is renewed at every process_with_file, clearing stale data on the file instance" do
39
+ f = Tempfile.new("test")
40
+ f.write("original") # 8 bytes
41
+ f.flush
42
+
43
+ a = klass.create! file: f
44
+ expect(a.result1).to eq 8
45
+ expect(a.result2).to eq 21
46
+
47
+ f.close!
48
+ end
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saviour
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Campos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-13 00:00:00.000000000 Z
11
+ date: 2018-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -195,6 +195,7 @@ files:
195
195
  - spec/feature/persisted_path_spec.rb
196
196
  - spec/feature/processors_api_spec.rb
197
197
  - spec/feature/reload_model_spec.rb
198
+ - spec/feature/reopens_file_at_every_process_spec.rb
198
199
  - spec/feature/rewind_source_before_read_spec.rb
199
200
  - spec/feature/transactional_behavior_spec.rb
200
201
  - spec/feature/uploader_declaration_spec.rb