kt-paperclip 6.2.2 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- data/.github/ISSUE_TEMPLATE/custom.md +10 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.hound.yml +363 -356
- data/.rubocop.yml +2 -0
- data/.travis.yml +0 -9
- data/Gemfile +3 -2
- data/README.md +37 -16
- data/lib/paperclip.rb +2 -1
- data/lib/paperclip/validators.rb +4 -4
- data/lib/paperclip/validators/attachment_content_type_validator.rb +8 -1
- data/lib/paperclip/validators/attachment_file_name_validator.rb +8 -1
- data/lib/paperclip/validators/attachment_size_validator.rb +17 -1
- data/lib/paperclip/version.rb +1 -1
- data/paperclip.gemspec +2 -2
- data/spec/paperclip/validators/attachment_content_type_validator_spec.rb +88 -0
- data/spec/paperclip/validators/attachment_file_name_validator_spec.rb +90 -0
- data/spec/paperclip/validators/attachment_size_validator_spec.rb +90 -0
- metadata +12 -9
- data/.github/issue_template.md +0 -3
@@ -205,6 +205,96 @@ describe Paperclip::Validators::AttachmentSizeValidator do
|
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
|
+
context "with add_validation_errors_to not set (implicitly :both)" do
|
209
|
+
it "adds error to both attribute and base" do
|
210
|
+
build_validator in: (5.kilobytes..10.kilobytes)
|
211
|
+
allow(@dummy).to receive(:avatar_file_size).and_return(11.kilobytes)
|
212
|
+
@validator.validate(@dummy)
|
213
|
+
|
214
|
+
assert @dummy.errors[:avatar_file_size].present?,
|
215
|
+
"Error not added to attribute"
|
216
|
+
|
217
|
+
assert @dummy.errors[:avatar].present?,
|
218
|
+
"Error not added to base attribute"
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
context "with add_validation_errors_to set to :attribute globally" do
|
223
|
+
before do
|
224
|
+
Paperclip.options[:add_validation_errors_to] = :attribute
|
225
|
+
end
|
226
|
+
|
227
|
+
after do
|
228
|
+
Paperclip.options[:add_validation_errors_to] = :both
|
229
|
+
end
|
230
|
+
|
231
|
+
it "only adds error to attribute not base" do
|
232
|
+
build_validator in: (5.kilobytes..10.kilobytes)
|
233
|
+
allow(@dummy).to receive(:avatar_file_size).and_return(11.kilobytes)
|
234
|
+
@validator.validate(@dummy)
|
235
|
+
|
236
|
+
assert @dummy.errors[:avatar_file_size].present?,
|
237
|
+
"Error not added to attribute"
|
238
|
+
|
239
|
+
assert @dummy.errors[:avatar].blank?,
|
240
|
+
"Error added to base attribute"
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
context "with add_validation_errors_to set to :base globally" do
|
245
|
+
before do
|
246
|
+
Paperclip.options[:add_validation_errors_to] = :base
|
247
|
+
end
|
248
|
+
|
249
|
+
after do
|
250
|
+
Paperclip.options[:add_validation_errors_to] = :both
|
251
|
+
end
|
252
|
+
|
253
|
+
it "only adds error to base not attribute" do
|
254
|
+
build_validator in: (5.kilobytes..10.kilobytes)
|
255
|
+
allow(@dummy).to receive(:avatar_file_size).and_return(11.kilobytes)
|
256
|
+
@validator.validate(@dummy)
|
257
|
+
|
258
|
+
assert @dummy.errors[:avatar].present?,
|
259
|
+
"Error not added to base attribute"
|
260
|
+
|
261
|
+
assert @dummy.errors[:avatar_file_size].blank?,
|
262
|
+
"Error added to attribute"
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
context "with add_validation_errors_to set to :attribute" do
|
267
|
+
it "only adds error to attribute not base" do
|
268
|
+
build_validator in: (5.kilobytes..10.kilobytes),
|
269
|
+
add_validation_errors_to: :attribute
|
270
|
+
|
271
|
+
allow(@dummy).to receive(:avatar_file_size).and_return(11.kilobytes)
|
272
|
+
@validator.validate(@dummy)
|
273
|
+
|
274
|
+
assert @dummy.errors[:avatar_file_size].present?,
|
275
|
+
"Error not added to attribute"
|
276
|
+
|
277
|
+
assert @dummy.errors[:avatar].blank?,
|
278
|
+
"Error added to base attribute"
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
context "with add_validation_errors_to set to :base" do
|
283
|
+
it "only adds error to base not attribute" do
|
284
|
+
build_validator in: (5.kilobytes..10.kilobytes),
|
285
|
+
add_validation_errors_to: :base
|
286
|
+
|
287
|
+
allow(@dummy).to receive(:avatar_file_size).and_return(11.kilobytes)
|
288
|
+
@validator.validate(@dummy)
|
289
|
+
|
290
|
+
assert @dummy.errors[:avatar].present?,
|
291
|
+
"Error not added to base attribute"
|
292
|
+
|
293
|
+
assert @dummy.errors[:avatar_file_size].blank?,
|
294
|
+
"Error added to attribute"
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
208
298
|
context "using the helper" do
|
209
299
|
before do
|
210
300
|
Dummy.validates_attachment_size :avatar, in: (5.kilobytes..10.kilobytes)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kt-paperclip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Surendra Singhi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -168,16 +168,16 @@ dependencies:
|
|
168
168
|
name: cucumber-expressions
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
173
|
+
version: '0'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
180
|
+
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: cucumber-rails
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -354,7 +354,9 @@ extensions: []
|
|
354
354
|
extra_rdoc_files: []
|
355
355
|
files:
|
356
356
|
- ".codeclimate.yml"
|
357
|
-
- ".github/
|
357
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
358
|
+
- ".github/ISSUE_TEMPLATE/custom.md"
|
359
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
358
360
|
- ".gitignore"
|
359
361
|
- ".hound.yml"
|
360
362
|
- ".rubocop.yml"
|
@@ -573,7 +575,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
573
575
|
requirements:
|
574
576
|
- - ">="
|
575
577
|
- !ruby/object:Gem::Version
|
576
|
-
version: 2.
|
578
|
+
version: 2.2.0
|
577
579
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
578
580
|
requirements:
|
579
581
|
- - ">="
|
@@ -581,7 +583,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
581
583
|
version: '0'
|
582
584
|
requirements:
|
583
585
|
- ImageMagick
|
584
|
-
|
586
|
+
rubyforge_project:
|
587
|
+
rubygems_version: 2.7.9
|
585
588
|
signing_key:
|
586
589
|
specification_version: 4
|
587
590
|
summary: File attachments as attributes for ActiveRecord
|
data/.github/issue_template.md
DELETED
@@ -1,3 +0,0 @@
|
|
1
|
-
## Deprecation notice
|
2
|
-
|
3
|
-
Paperclip is currently undergoing [deprecation in favor of ActiveStorage](https://github.com/thoughtbot/paperclip/blob/master/MIGRATING.md). Maintainers of this repository will no longer be tending to new issues. We're leaving the issues page open so Paperclip users can still see & search through old issues, and continue existing discussions if they wish.
|