volt 0.9.5.pre11 → 0.9.5.pre12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/volt/models/validations/validations.rb +1 -0
- data/lib/volt/models/validators/inclusion_validator.rb +25 -0
- data/lib/volt/server/html_parser/view_scope.rb +2 -0
- data/lib/volt/server/rack/asset_files.rb +1 -1
- data/lib/volt/version.rb +1 -1
- data/spec/apps/kitchen_sink/app/main/views/main/bindings.html +2 -0
- data/spec/models/validators/inclusion_validator_spec.rb +57 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e995f18c906a2379a9a631a32783910067905c19
|
4
|
+
data.tar.gz: fee2b9fc14654a0a3369b72f3e3a3d315af7715b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccaf2f6f632456efcb2851802d691ae992b150fe0cc84f05d8f7476cebb3b848556f18c11850052fde1a315af3d82fd4c3983c2d5bd1ba4092445451a5da3489
|
7
|
+
data.tar.gz: da08f6eeef5a27ac152827cde226539718e33fb33f6b3c3cdfa2f4a8f783be86b9a7bad1a514a6170b9a83132f55fee31aa59f611915c17bf8db9b1458bd04e1
|
data/CHANGELOG.md
CHANGED
@@ -17,6 +17,8 @@
|
|
17
17
|
- All volt CLI tasks now can run from inside of any directory in the volt app (or the root)
|
18
18
|
- Asset precompilation has been reworked to use Sprockets::Manifest. The results are written to /public, and an index.html file is created. The entire app loading up until the websocket connect can be served statically (via nginx for example) All js and css is written to a single file.
|
19
19
|
- The ```generate gem``` generator has been improved to setup a dummy app and integration specs out of the box.
|
20
|
+
- Tasks can now set (only set, not read) cookies on the client using the ```cookies``` collection.
|
21
|
+
- Added ```login_as(user)``` method to Tasks and HttpController's.
|
20
22
|
|
21
23
|
### Changed
|
22
24
|
- fix issue with ```raw``` and promises (#275)
|
@@ -25,6 +27,7 @@
|
|
25
27
|
- Redid the initializer load order so all initializers run before any controllers/models/views are loaded.
|
26
28
|
- Added error message for when an unserializable object is returned from a Task
|
27
29
|
- Fixed issue with disable_encryption option
|
30
|
+
- Fixed issue with select's not selecting options when options are dynamically loaded
|
28
31
|
|
29
32
|
## 0.9.4
|
30
33
|
### Lingo Change
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'volt/models/errors'
|
2
2
|
require 'volt/models/validators/format_validator'
|
3
3
|
require 'volt/models/validators/email_validator'
|
4
|
+
require 'volt/models/validators/inclusion_validator'
|
4
5
|
require 'volt/models/validators/length_validator'
|
5
6
|
require 'volt/models/validators/numericality_validator'
|
6
7
|
require 'volt/models/validators/phone_number_validator'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Volt
|
2
|
+
class InclusionValidator
|
3
|
+
def self.validate(model, field_name, args)
|
4
|
+
errors = {}
|
5
|
+
value = model.get(field_name)
|
6
|
+
|
7
|
+
if args.is_a?(Array)
|
8
|
+
list = args
|
9
|
+
message = nil
|
10
|
+
elsif args.is_a?(Hash)
|
11
|
+
list = args[:in]
|
12
|
+
message = args[:message]
|
13
|
+
fail 'A list to match against must be specified' unless list.is_a?(Array)
|
14
|
+
else
|
15
|
+
fail 'The arguments to inclusion validator must be an array or a hash'
|
16
|
+
end
|
17
|
+
|
18
|
+
unless list.include?(value)
|
19
|
+
errors[field_name] = [message || "must be one of #{list.join(', ')}"]
|
20
|
+
end
|
21
|
+
|
22
|
+
errors
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/volt/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Volt::InclusionValidator do
|
4
|
+
subject { Volt::InclusionValidator.validate(*use_params) }
|
5
|
+
let(:use_params) { [model, field_name, options] }
|
6
|
+
|
7
|
+
let(:model) { Volt::Model.new name: name }
|
8
|
+
let(:field_name) { :name }
|
9
|
+
let(:name) { 'John' }
|
10
|
+
|
11
|
+
describe '.validate' do
|
12
|
+
describe 'when options is an array' do
|
13
|
+
let(:options) { %w(John Susie Mary) }
|
14
|
+
|
15
|
+
describe 'when name is "John"' do
|
16
|
+
let(:name) { 'John' }
|
17
|
+
it { expect(subject).to eq({}) }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'when name is "Bill"' do
|
21
|
+
let(:name) { 'Bill' }
|
22
|
+
it do
|
23
|
+
expect(subject).to eq(name: ['must be one of John, Susie, Mary'])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'when options is a Hash' do
|
29
|
+
let(:options) do
|
30
|
+
{ in: %w(John Susie Mary), message: 'Choose one from the list.' }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'when name is "John"' do
|
34
|
+
let(:name) { 'John' }
|
35
|
+
it { expect(subject).to eq({}) }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'when name is "Bill"' do
|
39
|
+
let(:name) { 'Bill' }
|
40
|
+
it do
|
41
|
+
expect(subject).to eq(name: ['Choose one from the list.'])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'when options not a Fixnum or a Hash' do
|
47
|
+
let(:options) { 'string' }
|
48
|
+
|
49
|
+
it 'raises an exception' do
|
50
|
+
expect { subject }.to raise_error(
|
51
|
+
RuntimeError,
|
52
|
+
'The arguments to inclusion validator must be an array or a hash'
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.5.
|
4
|
+
version: 0.9.5.pre12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
@@ -484,6 +484,7 @@ files:
|
|
484
484
|
- lib/volt/models/validations/validations.rb
|
485
485
|
- lib/volt/models/validators/email_validator.rb
|
486
486
|
- lib/volt/models/validators/format_validator.rb
|
487
|
+
- lib/volt/models/validators/inclusion_validator.rb
|
487
488
|
- lib/volt/models/validators/length_validator.rb
|
488
489
|
- lib/volt/models/validators/numericality_validator.rb
|
489
490
|
- lib/volt/models/validators/phone_number_validator.rb
|
@@ -714,6 +715,7 @@ files:
|
|
714
715
|
- spec/models/validators/block_validations_spec.rb
|
715
716
|
- spec/models/validators/email_validator_spec.rb
|
716
717
|
- spec/models/validators/format_validator_spec.rb
|
718
|
+
- spec/models/validators/inclusion_validator_spec.rb
|
717
719
|
- spec/models/validators/length_validator_spec.rb
|
718
720
|
- spec/models/validators/phone_number_validator_spec.rb
|
719
721
|
- spec/models/validators/shared_examples_for_validators.rb
|
@@ -984,6 +986,7 @@ test_files:
|
|
984
986
|
- spec/models/validators/block_validations_spec.rb
|
985
987
|
- spec/models/validators/email_validator_spec.rb
|
986
988
|
- spec/models/validators/format_validator_spec.rb
|
989
|
+
- spec/models/validators/inclusion_validator_spec.rb
|
987
990
|
- spec/models/validators/length_validator_spec.rb
|
988
991
|
- spec/models/validators/phone_number_validator_spec.rb
|
989
992
|
- spec/models/validators/shared_examples_for_validators.rb
|