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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0747dcd299b6f0a1965c583f5f8b71a3c181355f7c98a36e180e5607172af79
4
- data.tar.gz: 1aac6b08756d18cd88869e7fa3b25b798a4bc0d543d9ebabe57436ce4edb3f0d
3
+ metadata.gz: f5512cd3673652315ed3ddc008ab718fe055d8a2771dd9505a3bfca27fdc4b14
4
+ data.tar.gz: ed92ca2f0112bfb8ff1c0c6e5464452bc282710b8168b4acc19f9dacfe870e36
5
5
  SHA512:
6
- metadata.gz: ca9ce86fa1f80542876bb174b4d74775e66849df6f067a4515fe0634d9936f69ac98b99bcf72a1c29181612a68a322241bf2d2b7f85ddc49f4af97984a0cf7a5
7
- data.tar.gz: 2c9c98ae090b2fe969cd4e806cddfad8b86d53738d5096e87d6dd15d75f591148533fb117b6186bfb4a364443d7e774117157676644b9ac194d09a9c07f6413c
6
+ metadata.gz: 3a6f13bc2d0b64f53b98232564715461708e4d6f0eac4966e4bbad5049e5e118c7a6c0c48a7cc08fa1b2a82e199640e17689ef5caf564a3b09d2cd40b41a7fe7
7
+ data.tar.gz: ef4713c314cfdfc59c6d4bb9551281b896c506303522316162594a8094f95966bc0fe4aad6f8c81117407bc58b95c713f4dfaea719831344764a28686cd5fce5
@@ -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 ||= Hash.new { [] }
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 ||= Hash.new { [] }
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
@@ -1,3 +1,3 @@
1
1
  module Saviour
2
- VERSION = "0.5.9"
2
+ VERSION = "0.5.10"
3
3
  end
@@ -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.9
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-22 00:00:00.000000000 Z
11
+ date: 2018-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord