validations-skipper 0.1.0 → 0.1.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/lib/validations_skipper.rb +2 -1
- data/test/test_validations_skipper.rb +34 -0
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 244ce5215d144be6b90279445dc7e35f30f5f62169329e11e9d28e28bd83b519
|
4
|
+
data.tar.gz: bcd3f5ce9d8ac2a459e5b007e05f141bd813baf0d00a5418b0015b1b9e07a9a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ec4e145886ee718b0f843bd4dea2b196be551580f2197225c419a057da748c53251370a7c192c78b9cddf2093a877abc976423423fb5b26fbed2d2d86c46393
|
7
|
+
data.tar.gz: 06a9c006bae4bd537d75686ba17f718c7da7a0650f403732a8e53a2fb3207b033810a26532a8bb02aac1a22a776097bae65ec1e28d339bc58f752ea25efde7e6
|
data/lib/validations_skipper.rb
CHANGED
@@ -4,7 +4,8 @@ module ValidationsSkipable
|
|
4
4
|
attr_accessor :skip_validations
|
5
5
|
|
6
6
|
def initialize(*)
|
7
|
-
|
7
|
+
instance_methods = self.class.instance_methods + self.class.private_instance_methods
|
8
|
+
@original_methods = instance_methods.map do |instance_method|
|
8
9
|
[instance_method, method(instance_method)]
|
9
10
|
end.to_h
|
10
11
|
super
|
@@ -78,4 +78,38 @@ class TestValidationsSkipper < Minitest::Test
|
|
78
78
|
|
79
79
|
assert_equal(@object.valid?, false)
|
80
80
|
end
|
81
|
+
|
82
|
+
class ClassWithPrivateValidation
|
83
|
+
include ActiveModel::Validations
|
84
|
+
include ValidationsSkipable
|
85
|
+
|
86
|
+
validate :private_validation_method
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def private_validation_method
|
91
|
+
errors.add(:column, 'An error message')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_skipping_private_validation
|
96
|
+
@object = ClassWithPrivateValidation.new
|
97
|
+
@object.skip_validations = [:private_validation_method]
|
98
|
+
|
99
|
+
assert_equal(@object.valid?, true)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_not_skipping_private_validation
|
103
|
+
@object = ClassWithPrivateValidation.new
|
104
|
+
|
105
|
+
assert_equal(@object.valid?, false)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_toggleing_skipping_validation
|
109
|
+
@object = ClassWithPrivateValidation.new
|
110
|
+
@object.skip_validations = [:private_validation_method]
|
111
|
+
@object.skip_validations = []
|
112
|
+
|
113
|
+
assert_equal(@object.valid?, false)
|
114
|
+
end
|
81
115
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validations-skipper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Cordeiro Costa
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '5.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '5.2'
|
55
55
|
description: |-
|
56
56
|
validations-skipper is a gem that enables objects
|
57
57
|
to skip specified validations with ease.
|
@@ -68,7 +68,7 @@ homepage: https://github.com/Victorcorcos/validations-skipper
|
|
68
68
|
licenses:
|
69
69
|
- MIT
|
70
70
|
metadata: {}
|
71
|
-
post_install_message:
|
71
|
+
post_install_message:
|
72
72
|
rdoc_options: []
|
73
73
|
require_paths:
|
74
74
|
- lib
|
@@ -83,9 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
|
87
|
-
|
88
|
-
signing_key:
|
86
|
+
rubygems_version: 3.0.9
|
87
|
+
signing_key:
|
89
88
|
specification_version: 4
|
90
89
|
summary: validations-skipper is a gem that enables objects to skip specified validations
|
91
90
|
with ease. It can be applied to ActiveRecord::Base classes.
|