database_validations 0.7.1 → 0.7.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0272e7610a4c92445421092f94faff13711f4b235d74340ee924b946dfe4d487
|
4
|
+
data.tar.gz: 0646b4e6bab48d3e48c4860d715e600a7f02211be18676d0c5258e33b490e1e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a475cdbd890674df1b3ed1f7f493c0426638016e5c4a20e8a5f333cb7f4d3101581a40478d45c2dedde0fea77fbdd1589a7947d8ab6c7d4f26008c829b066db
|
7
|
+
data.tar.gz: b7e63a9b639fcb81a3f7921336563d9c4cb5d68e27c27c80863ad0ed56d40977ffb9f93ba6732ef469983052f174374e30f38e42cf732833b51898ceee81f135
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# @scope Models
|
2
2
|
#
|
3
|
-
# Matches when model
|
3
|
+
# Matches when model or instance of model validates database uniqueness of some field.
|
4
4
|
#
|
5
5
|
# Modifiers:
|
6
6
|
# * `with_message(message)` -- specifies a message of the error;
|
@@ -13,6 +13,12 @@
|
|
13
13
|
# ```ruby
|
14
14
|
# it { expect(Model).to validate_db_uniqueness_of(:field) }
|
15
15
|
# ```
|
16
|
+
#
|
17
|
+
# is the same as
|
18
|
+
#
|
19
|
+
#```ruby
|
20
|
+
# it { expect(Model.new).to validate_db_uniqueness_of(:field) }
|
21
|
+
# ```
|
16
22
|
RSpec::Matchers.define :validate_db_uniqueness_of do |field|
|
17
23
|
chain(:with_message) do |message|
|
18
24
|
@message = message
|
@@ -30,9 +36,11 @@ RSpec::Matchers.define :validate_db_uniqueness_of do |field|
|
|
30
36
|
@index_name = index_name
|
31
37
|
end
|
32
38
|
|
33
|
-
match do |
|
39
|
+
match do |object|
|
34
40
|
@validators = []
|
35
41
|
|
42
|
+
model = object.is_a?(Class) ? object : object.class
|
43
|
+
|
36
44
|
DatabaseValidations::Helpers.each_validator(model) do |validator|
|
37
45
|
@validators << {
|
38
46
|
field: validator.field,
|