valhammer 0.2.0 → 0.2.1
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/valhammer/validations.rb +2 -2
- data/lib/valhammer/version.rb +1 -1
- data/spec/lib/valhammer/validations_spec.rb +10 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ace2f365a3a9e8e0b69f9f77f94c20e3af74809
|
4
|
+
data.tar.gz: a4d6c5a97f605f7271c08ec7a2cee5b040829d74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb8fdaf62845a94eb71156366265cf3490b6d92e5c4fe3d815fb72fbf758925d6cf776bda908a0e38c04faf3ee0c113ccfc868fec2cef0b99ebf918753caf4fd
|
7
|
+
data.tar.gz: e447884f22b1bec71ca782b8a9f9b72bf0217f9894b15f2a7417b321093f8b1ea8627388a4966898918e908fc457d263fb21582a4fb3bcf683dca76115686098
|
@@ -4,7 +4,7 @@ module Valhammer
|
|
4
4
|
numericality: true, length: true,
|
5
5
|
inclusion: true }.freeze
|
6
6
|
|
7
|
-
VALHAMMER_EXCLUDED_FIELDS = %w(created_at updated_at)
|
7
|
+
VALHAMMER_EXCLUDED_FIELDS = %w(created_at updated_at).freeze
|
8
8
|
|
9
9
|
private_constant :VALHAMMER_DEFAULT_OPTS, :VALHAMMER_EXCLUDED_FIELDS
|
10
10
|
|
@@ -74,7 +74,7 @@ module Valhammer
|
|
74
74
|
nullable = scope.select { |c| columns_hash[c].null }
|
75
75
|
|
76
76
|
opts = { allow_nil: true }
|
77
|
-
opts[:scope] = scope if scope.any?
|
77
|
+
opts[:scope] = scope.map(&:to_sym) if scope.any?
|
78
78
|
opts[:if] = -> { nullable.all? { |c| send(c) } } if nullable.any?
|
79
79
|
opts
|
80
80
|
end
|
data/lib/valhammer/version.rb
CHANGED
@@ -2,7 +2,7 @@ RSpec.describe Valhammer::Validations do
|
|
2
2
|
around do |example|
|
3
3
|
ActiveRecord::Base.transaction do
|
4
4
|
example.run
|
5
|
-
|
5
|
+
raise(ActiveRecord::Rollback)
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -93,6 +93,13 @@ RSpec.describe Valhammer::Validations do
|
|
93
93
|
it { is_expected.not_to include(a_validator_for(:id, :uniqueness)) }
|
94
94
|
it { is_expected.to include(a_validator_for(:identifier, :uniqueness)) }
|
95
95
|
it { is_expected.not_to include(a_validator_for(:mail, :uniqueness)) }
|
96
|
+
|
97
|
+
it 'creates a case sensitive validator' do
|
98
|
+
opts = { case_sensitive: true, allow_nil: true }
|
99
|
+
|
100
|
+
expect(subject)
|
101
|
+
.to include(a_validator_for(:identifier, :uniqueness, opts))
|
102
|
+
end
|
96
103
|
end
|
97
104
|
|
98
105
|
context 'with a partial unique index' do
|
@@ -103,7 +110,7 @@ RSpec.describe Valhammer::Validations do
|
|
103
110
|
|
104
111
|
context 'with a composite unique index' do
|
105
112
|
let(:opts) do
|
106
|
-
{ scope: [
|
113
|
+
{ scope: [:organisation_id], case_sensitive: true, allow_nil: true }
|
107
114
|
end
|
108
115
|
|
109
116
|
it { is_expected.to include(a_validator_for(:name, :uniqueness, opts)) }
|
@@ -113,7 +120,7 @@ RSpec.describe Valhammer::Validations do
|
|
113
120
|
subject { Capability.validators }
|
114
121
|
|
115
122
|
let(:opts) do
|
116
|
-
{ scope: [
|
123
|
+
{ scope: [:organisation_id], case_sensitive: true, allow_nil: true,
|
117
124
|
if: an_instance_of(Proc) }
|
118
125
|
end
|
119
126
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valhammer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun Mangelsdorf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -231,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
231
|
version: '0'
|
232
232
|
requirements: []
|
233
233
|
rubyforge_project:
|
234
|
-
rubygems_version: 2.
|
234
|
+
rubygems_version: 2.5.1
|
235
235
|
signing_key:
|
236
236
|
specification_version: 4
|
237
237
|
summary: Automatically validate ActiveRecord models based on the database schema.
|