saviour 0.5.1 → 0.5.2
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/.travis.yml +1 -0
- data/lib/saviour/base_uploader.rb +1 -1
- data/lib/saviour/version.rb +1 -1
- data/spec/feature/stash_spec.rb +60 -0
- 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: e1da8130c0e682e7d8c0d86a936a498a8d70d85f5feb8b94d287217062bbb69c
|
4
|
+
data.tar.gz: ce046b7ff42417a32229f5ba4ee717ecf4a49c1d07ab0923aae3b96152d998ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b532b295d640352549307de69ac0bf4d4ca63cb1f8312d4e43f97f98d28a122b4249e31e44dc4ee5d99e24a811d31e63f1dfb22d4cda280f20ba634a077f571
|
7
|
+
data.tar.gz: da792dd8c19baa075f43ba22062f7f8bc920e985f465c5b09660e31e762f5b8c13e93ef3847c9d7fdefe673bbba3dac60c58a920240f76cb91d3611536399741
|
data/.travis.yml
CHANGED
data/lib/saviour/version.rb
CHANGED
data/spec/feature/stash_spec.rb
CHANGED
@@ -83,4 +83,64 @@ describe "stash data on process" do
|
|
83
83
|
expect(a.size_file).to eq 74
|
84
84
|
expect(a.size_file_thumb).to eq 31
|
85
85
|
end
|
86
|
+
|
87
|
+
it 'stash deep merges' do
|
88
|
+
uploader = Class.new(Saviour::BaseUploader) {
|
89
|
+
store_dir { "/store/dir" }
|
90
|
+
|
91
|
+
process_with_file do |file, filename|
|
92
|
+
stash(model: { file_size: File.size(file.path) })
|
93
|
+
|
94
|
+
[file, filename]
|
95
|
+
end
|
96
|
+
|
97
|
+
process_with_file do |file, filename|
|
98
|
+
stash(model: { name: "Foo" })
|
99
|
+
|
100
|
+
[file, filename]
|
101
|
+
end
|
102
|
+
|
103
|
+
after_upload do |stash|
|
104
|
+
model.update_attributes!(stash[:model])
|
105
|
+
end
|
106
|
+
}
|
107
|
+
|
108
|
+
klass = Class.new(Test) { include Saviour::Model }
|
109
|
+
klass.attach_file :file, uploader
|
110
|
+
|
111
|
+
a = klass.create! file: Saviour::StringSource.new("a" * 74, "file.txt")
|
112
|
+
|
113
|
+
expect(a.file_size).to eq 74
|
114
|
+
expect(a.name).to eq 'Foo'
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'after_upload can be declared multiple times' do
|
118
|
+
uploader = Class.new(Saviour::BaseUploader) {
|
119
|
+
store_dir { "/store/dir" }
|
120
|
+
|
121
|
+
process_with_file do |file, filename|
|
122
|
+
stash(file_size: File.size(file.path), name: "Foo")
|
123
|
+
|
124
|
+
[file, filename]
|
125
|
+
end
|
126
|
+
|
127
|
+
after_upload do |stash|
|
128
|
+
model.update_attributes!(file_size: stash[:file_size])
|
129
|
+
end
|
130
|
+
|
131
|
+
after_upload do |stash|
|
132
|
+
model.update_attributes!(name: stash[:name])
|
133
|
+
end
|
134
|
+
}
|
135
|
+
|
136
|
+
klass = Class.new(Test) { include Saviour::Model }
|
137
|
+
klass.attach_file :file, uploader
|
138
|
+
|
139
|
+
# 1- insert, 2- set file path 3+4- two after_upload' updates
|
140
|
+
expect_to_yield_queries(count: 4) do
|
141
|
+
a = klass.create! file: Saviour::StringSource.new("a" * 74, "file.txt")
|
142
|
+
expect(a.file_size).to eq 74
|
143
|
+
expect(a.name).to eq 'Foo'
|
144
|
+
end
|
145
|
+
end
|
86
146
|
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.5.
|
4
|
+
version: 0.5.2
|
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-03-
|
11
|
+
date: 2018-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|