saviour 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c4a0898f2a80dfb611406f5d9ad72a6abdd8a1dc36716013f7d6c375041a603
4
- data.tar.gz: b394cc24a4e380a64948026543489c2f9f40cdc91023d6009642b351e3162dea
3
+ metadata.gz: 7f06409c24b72526d31e275f0960f5bf754013f3d53497a81a94bef09c574407
4
+ data.tar.gz: 318b4ab1d8640c87302483853419b03cea9495af7e299c124f3fab8f6be5b8df
5
5
  SHA512:
6
- metadata.gz: 33b0babd6aac01fda54898026e70fb717b65819c7cbddfc721baa6c0ec5f2bff19b05edbe7b465ff972e3c9ce14db9a9a8ceee180f073d92f92b8c7741fc3748
7
- data.tar.gz: ac423bdfc6ed48c368ca92e6e4aeca395ceb51ae4d14d363971b27d656777e8974c5514a6db959ca89154c95c5a8fc484cdad26e478198ea17775abda466250a
6
+ metadata.gz: dcb4f0d8c74ff3d2bf6354c4012f65e5869009a75ca0d23b773156527767b880c2f328de365a6eb8dc5e371f074dedd37785436c545edf6f3fd034971f819acf
7
+ data.tar.gz: ff1b6c64937fd164ab1bdc1e5e7d76c81d0116c303696c17b86b40f8514b6e9bb58de18b4fa53bcc79f6ec67a991c9878a6db0e396d06f4db2921c5b9fc6c9ad
@@ -54,8 +54,8 @@ module Saviour
54
54
  new_file
55
55
  end
56
56
 
57
- def dup
58
- new_file = Saviour::File.new(@uploader_klass, @model, @attached_as)
57
+ def dup(new_model)
58
+ new_file = Saviour::File.new(@uploader_klass, new_model, @attached_as)
59
59
 
60
60
  if persisted?
61
61
  new_file.assign(Saviour::StringSource.new(read, filename))
@@ -24,7 +24,8 @@ module Saviour
24
24
  duped = super
25
25
 
26
26
  self.class.attached_files.each do |attach_as|
27
- duped.instance_variable_set("@__uploader_#{attach_as}", send(attach_as).dup)
27
+ duped[attach_as] = nil
28
+ duped.instance_variable_set("@__uploader_#{attach_as}", send(attach_as).dup(duped))
28
29
  end
29
30
 
30
31
  duped
@@ -1,3 +1,3 @@
1
1
  module Saviour
2
- VERSION = "0.5.7"
2
+ VERSION = "0.5.8"
3
3
  end
@@ -215,22 +215,28 @@ describe "CRUD" do
215
215
  expect(Saviour::Config.storage.exists?(b[:file])).to be_truthy
216
216
  end
217
217
 
218
- it "creates a non persisted file attachment" do
218
+ it "creates a non persisted file attachment with initially clear db paths" do
219
219
  a = klass.create! file: Saviour::StringSource.new("contents", "file.txt")
220
220
  expect(Saviour::Config.storage.exists?(a[:file])).to be_truthy
221
221
 
222
222
  b = a.dup
223
223
  expect(b).to_not be_persisted
224
224
  expect(b.file).to_not be_persisted
225
+ expect(b[:file]).to be_nil
225
226
  end
226
227
 
227
228
  it "can be saved" do
228
229
  a = klass.create! file: Saviour::StringSource.new("contents", "file.txt")
230
+ path_a = a[:file]
231
+
229
232
  b = a.dup
230
233
  b.save!
234
+ path_b = b[:file]
231
235
 
232
- expect(Saviour::Config.storage.exists?(b[:file])).to be_truthy
233
- expect(Saviour::Config.storage.read(a[:file])).to eq Saviour::Config.storage.read(b[:file])
236
+ expect(path_a).to eq "/store/dir/#{a.id}/file.txt"
237
+ expect(path_b).to eq "/store/dir/#{b.id}/file.txt"
238
+ expect(Saviour::Config.storage.exists?(path_b)).to be_truthy
239
+ expect(Saviour::Config.storage.read(path_a)).to eq Saviour::Config.storage.read(path_b)
234
240
  end
235
241
  end
236
242
 
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.5.7
4
+ version: 0.5.8
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-05-10 00:00:00.000000000 Z
11
+ date: 2018-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord