saviour 0.5.1 → 0.5.2

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: d30fa955590994c40acee59df17db7840c20d772afd8532e772813f53cdf9588
4
- data.tar.gz: 37f60dce478723b85d08ba25e971497b9a20829fab51c0d6f46e2422661cfa5e
3
+ metadata.gz: e1da8130c0e682e7d8c0d86a936a498a8d70d85f5feb8b94d287217062bbb69c
4
+ data.tar.gz: ce046b7ff42417a32229f5ba4ee717ecf4a49c1d07ab0923aae3b96152d998ec
5
5
  SHA512:
6
- metadata.gz: 0055e48b2d02bc40270c32ddf797089c0ef4c7fcfc1d29ecae04b2abd6a72ce952b2faf319bed50619b5497eab337001e950edb2c4b0a06a478dce7fefbc8941
7
- data.tar.gz: bb9bd3648caaa9fc1c379f374f7c97f5e131916ba3ffa600f691db28ae90853afed59432b86f359b0f1d93064d3efb683f2fe4c7f0f58dc8d118992569d764c6
6
+ metadata.gz: 5b532b295d640352549307de69ac0bf4d4ca63cb1f8312d4e43f97f98d28a122b4249e31e44dc4ee5d99e24a811d31e63f1dfb22d4cda280f20ba634a077f571
7
+ data.tar.gz: da792dd8c19baa075f43ba22062f7f8bc920e985f465c5b09660e31e762f5b8c13e93ef3847c9d7fdefe673bbba3dac60c58a920240f76cb91d3611536399741
data/.travis.yml CHANGED
@@ -5,6 +5,7 @@ rvm:
5
5
  - 2.2.8
6
6
  - 2.3.5
7
7
  - 2.4.2
8
+ - 2.5.0
8
9
 
9
10
  gemfile:
10
11
  - gemfiles/5.0.gemfile
@@ -53,7 +53,7 @@ module Saviour
53
53
  end
54
54
 
55
55
  def stash(hash)
56
- @stash.merge!(hash)
56
+ @stash.deep_merge!(hash)
57
57
  end
58
58
 
59
59
  def stashed
@@ -1,3 +1,3 @@
1
1
  module Saviour
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -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.1
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-08 00:00:00.000000000 Z
11
+ date: 2018-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord