saviour 0.5.9 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/saviour/integrator.rb +3 -2
- data/lib/saviour/version.rb +1 -1
- data/spec/models/model_spec.rb +30 -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: f5512cd3673652315ed3ddc008ab718fe055d8a2771dd9505a3bfca27fdc4b14
|
4
|
+
data.tar.gz: ed92ca2f0112bfb8ff1c0c6e5464452bc282710b8168b4acc19f9dacfe870e36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a6f13bc2d0b64f53b98232564715461708e4d6f0eac4966e4bbad5049e5e118c7a6c0c48a7cc08fa1b2a82e199640e17689ef5caf564a3b09d2cd40b41a7fe7
|
7
|
+
data.tar.gz: ef4713c314cfdfc59c6d4bb9551281b896c506303522316162594a8094f95966bc0fe4aad6f8c81117407bc58b95c713f4dfaea719831344764a28686cd5fce5
|
data/lib/saviour/integrator.rb
CHANGED
@@ -102,14 +102,15 @@ module Saviour
|
|
102
102
|
end
|
103
103
|
|
104
104
|
@klass.class_attribute :__saviour_validations
|
105
|
+
@klass.__saviour_validations = Hash.new { [] }
|
105
106
|
|
106
107
|
@klass.define_singleton_method("attach_validation") do |attach_as, method_name = nil, &block|
|
107
|
-
self.__saviour_validations
|
108
|
+
self.__saviour_validations = self.__saviour_validations.dup
|
108
109
|
self.__saviour_validations[attach_as] += [{ method_or_block: method_name || block, type: :memory }]
|
109
110
|
end
|
110
111
|
|
111
112
|
@klass.define_singleton_method("attach_validation_with_file") do |attach_as, method_name = nil, &block|
|
112
|
-
self.__saviour_validations
|
113
|
+
self.__saviour_validations = self.__saviour_validations.dup
|
113
114
|
self.__saviour_validations[attach_as] += [{ method_or_block: method_name || block, type: :file }]
|
114
115
|
end
|
115
116
|
end
|
data/lib/saviour/version.rb
CHANGED
data/spec/models/model_spec.rb
CHANGED
@@ -79,4 +79,34 @@ describe Saviour do
|
|
79
79
|
expect(klass3.attached_files).to eq([:file_thumb_2, :file_thumb_3])
|
80
80
|
expect(klass3.attached_followers_per_leader).to eq({file_thumb_2: [:file_thumb_3]})
|
81
81
|
end
|
82
|
+
|
83
|
+
it "subclasses can have independent validations" do
|
84
|
+
uploader = Class.new(Saviour::BaseUploader) do
|
85
|
+
store_dir { "/store/dir" }
|
86
|
+
end
|
87
|
+
|
88
|
+
klass = Class.new(Test) do
|
89
|
+
include Saviour::Model
|
90
|
+
end
|
91
|
+
|
92
|
+
klass2 = Class.new(klass) do
|
93
|
+
attach_file :file, uploader
|
94
|
+
attach_validation :file do |contents, filename|
|
95
|
+
# pass
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
klass3 = Class.new(klass) do
|
100
|
+
attach_file :file_thumb_2, uploader
|
101
|
+
attach_validation :file_thumb_2 do |contents, filename|
|
102
|
+
# pass
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
expect(klass2.__saviour_validations.size).to eq 1
|
107
|
+
expect(klass2.__saviour_validations.keys).to eq [:file]
|
108
|
+
|
109
|
+
expect(klass3.__saviour_validations.size).to eq 1
|
110
|
+
expect(klass3.__saviour_validations.keys).to eq [:file_thumb_2]
|
111
|
+
end
|
82
112
|
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.10
|
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-06-
|
11
|
+
date: 2018-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|