valhammer 0.2.0 → 0.2.1

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
  SHA1:
3
- metadata.gz: a17bafd0cee09ccf70430c604c381aa2cf9bcd1d
4
- data.tar.gz: 1104fae993e967539bf5f96eb2f2b917cfe9fc9f
3
+ metadata.gz: 0ace2f365a3a9e8e0b69f9f77f94c20e3af74809
4
+ data.tar.gz: a4d6c5a97f605f7271c08ec7a2cee5b040829d74
5
5
  SHA512:
6
- metadata.gz: e48594d0e505482ab9a8915c7336890351e245dd97ba4849ddcf604ae836ef3421b07985a93338d984ba21475064332b3c0008a739b3b515ed360fdf8344fb55
7
- data.tar.gz: 75fc238355ba8e2338af112a085f340f427c32c8a0e0b9bfea5fcdc0d89369694d426d15b45055620e2600a7efc9ca5a38e08a683a74b0b94cc09ba948002910
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
@@ -1,3 +1,3 @@
1
1
  module Valhammer
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'.freeze
3
3
  end
@@ -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
- fail(ActiveRecord::Rollback)
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: ['organisation_id'], case_sensitive: true, allow_nil: true }
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: ['organisation_id'], case_sensitive: true, allow_nil: true,
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.0
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: 2015-10-21 00:00:00.000000000 Z
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.4.5
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.