rom-rails 0.4.0 → 0.5.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/rom/rails/model/validator/uniqueness_validator.rb +5 -1
- data/lib/rom/rails/railtie.rb +1 -0
- data/lib/rom/rails/version.rb +1 -1
- data/rom-rails.gemspec +1 -1
- data/spec/unit/validator_spec.rb +21 -0
- metadata +6 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e97b52065b6d47076303cb3e7b01bf0b2b26b2d2
|
4
|
+
data.tar.gz: 3a20e700c19316431532ea0780e176597e964a04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf5e13ef79c24653c6fb3a83b93de8a01c11a3f9883b7f2dfb1cf0a6030a95bced0b82432d62c174bc05c48f1ef416fce6a50653d80005fee31e2a7c335741d7
|
7
|
+
data.tar.gz: 2b939dbc62be89dbaee3e7e9ccafcaa8f93e036b61ad3d9820024d374a8e8fb4e0a75b958c9eef37f93ffc6309daf5cb63c1e341e92bcc4f13866c2830a95a26
|
data/README.md
CHANGED
@@ -23,6 +23,13 @@ ships with:
|
|
23
23
|
* Mapper generators
|
24
24
|
* Command generators
|
25
25
|
|
26
|
+
## Tests
|
27
|
+
|
28
|
+
To run tests:
|
29
|
+
|
30
|
+
RAILS_ENV=test bundle exec rake db:migrate
|
31
|
+
bundle exec rake
|
32
|
+
|
26
33
|
## Issues
|
27
34
|
|
28
35
|
Please report any issues in the main [rom-rb/rom](https://github.com/rom-rb/rom/issues) issue tracker.
|
@@ -43,7 +43,11 @@ module ROM
|
|
43
43
|
#
|
44
44
|
# @api private
|
45
45
|
def relation
|
46
|
-
|
46
|
+
if relation_name
|
47
|
+
rom.relations[relation_name]
|
48
|
+
else
|
49
|
+
raise "relation must be specified to use uniqueness validation"
|
50
|
+
end
|
47
51
|
end
|
48
52
|
|
49
53
|
# Relation name defined on the validator class
|
data/lib/rom/rails/railtie.rb
CHANGED
data/lib/rom/rails/version.rb
CHANGED
data/rom-rails.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_runtime_dependency 'rom', '~> 0.
|
20
|
+
spec.add_runtime_dependency 'rom', '~> 0.9.0.beta1'
|
21
21
|
spec.add_runtime_dependency 'addressable', '~> 2.3'
|
22
22
|
spec.add_runtime_dependency 'charlatan', '~> 0.1'
|
23
23
|
spec.add_runtime_dependency 'virtus', '~> 1.0', '>= 1.0.5'
|
data/spec/unit/validator_spec.rb
CHANGED
@@ -122,6 +122,27 @@ describe 'Validation' do
|
|
122
122
|
expect(validator).to be_valid
|
123
123
|
end
|
124
124
|
end
|
125
|
+
|
126
|
+
describe 'with missing relation' do
|
127
|
+
let(:user_validator) do
|
128
|
+
Class.new {
|
129
|
+
include ROM::Model::Validator
|
130
|
+
|
131
|
+
validates :email, uniqueness: true
|
132
|
+
|
133
|
+
def self.name
|
134
|
+
'User'
|
135
|
+
end
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'raises a helpful error' do
|
140
|
+
validator = user_validator.new(user_attrs.new)
|
141
|
+
expect {
|
142
|
+
validator.valid?
|
143
|
+
}.to raise_error(/relation must be specified/)
|
144
|
+
end
|
145
|
+
end
|
125
146
|
end
|
126
147
|
|
127
148
|
describe '#method_missing' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rom
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 0.8.0
|
19
|
+
version: 0.9.0.beta1
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 0.8.0
|
26
|
+
version: 0.9.0.beta1
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: addressable
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -276,9 +270,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
276
270
|
version: '0'
|
277
271
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
278
272
|
requirements:
|
279
|
-
- - "
|
273
|
+
- - ">"
|
280
274
|
- !ruby/object:Gem::Version
|
281
|
-
version:
|
275
|
+
version: 1.3.1
|
282
276
|
requirements: []
|
283
277
|
rubyforge_project:
|
284
278
|
rubygems_version: 2.4.5
|