saviour 0.5.7 → 0.5.8
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 +4 -4
- data/lib/saviour/file.rb +2 -2
- data/lib/saviour/model.rb +2 -1
- data/lib/saviour/version.rb +1 -1
- data/spec/feature/crud_workflows_spec.rb +9 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f06409c24b72526d31e275f0960f5bf754013f3d53497a81a94bef09c574407
|
4
|
+
data.tar.gz: 318b4ab1d8640c87302483853419b03cea9495af7e299c124f3fab8f6be5b8df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcb4f0d8c74ff3d2bf6354c4012f65e5869009a75ca0d23b773156527767b880c2f328de365a6eb8dc5e371f074dedd37785436c545edf6f3fd034971f819acf
|
7
|
+
data.tar.gz: ff1b6c64937fd164ab1bdc1e5e7d76c81d0116c303696c17b86b40f8514b6e9bb58de18b4fa53bcc79f6ec67a991c9878a6db0e396d06f4db2921c5b9fc6c9ad
|
data/lib/saviour/file.rb
CHANGED
@@ -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,
|
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))
|
data/lib/saviour/model.rb
CHANGED
@@ -24,7 +24,8 @@ module Saviour
|
|
24
24
|
duped = super
|
25
25
|
|
26
26
|
self.class.attached_files.each do |attach_as|
|
27
|
-
duped
|
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
|
data/lib/saviour/version.rb
CHANGED
@@ -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(
|
233
|
-
expect(
|
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.
|
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-
|
11
|
+
date: 2018-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|