volt 0.8.23 → 0.8.24
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/VERSION +1 -1
- data/lib/volt/extra_core/class.rb +27 -0
- data/lib/volt/extra_core/extra_core.rb +1 -0
- data/lib/volt/models/validations.rb +5 -13
- data/lib/volt/page/bindings/template_binding.rb +7 -4
- data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +6 -0
- data/spec/apps/kitchen_sink/app/main/views/main/main.html +1 -1
- data/spec/extra_core/class_spec.rb +33 -0
- data/spec/integration/user_spec.rb +20 -0
- data/spec/page/bindings/template_binding_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/templates/project/app/main/controllers/main_controller.rb +6 -0
- data/templates/project/app/main/views/main/main.html.tt +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4baa719966706c9e9196f42e061abb6e95e7d54c
|
4
|
+
data.tar.gz: 2b9fcde56cc4cd12ac1503dd464f9444a1e9a866
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a18bd3212878144d412b33647d98570760c49d2fffcd598083e452dd6c9a3696f8df716e01f4328aff654edb2eef24664c28af7c91151944d37ef64abb146f4c
|
7
|
+
data.tar.gz: 48f4412a6d4064edf20d9006e539ec74230d49d71b27749a42230c13092ffaba650f3625b5078145be5afa6bef13bc0007af620cab7f11cd3e112bcc5348bf4a
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.24
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Class
|
2
|
+
# Provides a way to make class attributes that inherit. Pass
|
3
|
+
# in symbols for attribute names
|
4
|
+
def class_attribute(*attrs)
|
5
|
+
attrs.each do |name|
|
6
|
+
define_singleton_method(name) { nil }
|
7
|
+
|
8
|
+
ivar = "@#{name}"
|
9
|
+
|
10
|
+
define_singleton_method("#{name}=") do |val|
|
11
|
+
singleton_class.class_eval do
|
12
|
+
remove_possible_method(name)
|
13
|
+
define_method(name) { val }
|
14
|
+
end
|
15
|
+
|
16
|
+
val
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Removes a method if it is defined.
|
22
|
+
def remove_possible_method(method)
|
23
|
+
if method_defined?(method) || private_method_defined?(method)
|
24
|
+
undef_method(method)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -6,6 +6,7 @@ require 'volt/extra_core/stringify_keys'
|
|
6
6
|
require 'volt/extra_core/string'
|
7
7
|
require 'volt/extra_core/numeric'
|
8
8
|
require 'volt/extra_core/true_false'
|
9
|
+
require 'volt/extra_core/class'
|
9
10
|
if RUBY_PLATFORM == 'opal'
|
10
11
|
# TODO: != does not work with opal for some reason
|
11
12
|
else
|
@@ -13,26 +13,18 @@ module Volt
|
|
13
13
|
if field_name || options
|
14
14
|
raise "validate should be passed a field name and options or a block, not both."
|
15
15
|
end
|
16
|
-
|
17
|
-
|
16
|
+
self.custom_validations ||= []
|
17
|
+
custom_validations << block
|
18
18
|
else
|
19
|
-
|
20
|
-
|
19
|
+
self.validations ||= {}
|
20
|
+
validations[field_name] = options
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
24
|
-
# TODO: For some reason attr_reader on a class doesn't work in Opal
|
25
|
-
def validations
|
26
|
-
@validations
|
27
|
-
end
|
28
|
-
|
29
|
-
def custom_validations
|
30
|
-
@custom_validations
|
31
|
-
end
|
32
23
|
end
|
33
24
|
|
34
25
|
def self.included(base)
|
35
26
|
base.send :extend, ClassMethods
|
27
|
+
base.class_attribute(:custom_validations, :validations)
|
36
28
|
end
|
37
29
|
|
38
30
|
# Once a field is ready, we can use include_in_errors! to start
|
@@ -86,12 +86,15 @@ module Volt
|
|
86
86
|
if check_for_template?(path)
|
87
87
|
controller = nil
|
88
88
|
|
89
|
-
# Don't return a controller if we are just getting another section
|
90
|
-
# from the same controller
|
91
89
|
if path_position >= 1
|
92
|
-
|
93
|
-
|
90
|
+
init_method = full_path[2]
|
91
|
+
else
|
92
|
+
init_method = full_path[3]
|
94
93
|
end
|
94
|
+
|
95
|
+
# Lookup the controller
|
96
|
+
controller = [full_path[0], full_path[1] + '_controller', init_method]
|
97
|
+
|
95
98
|
return path, controller
|
96
99
|
end
|
97
100
|
end
|
@@ -35,4 +35,10 @@ class MainController < Volt::ModelController
|
|
35
35
|
def main_path
|
36
36
|
params._controller.or('main') + '/' + params._action.or('index')
|
37
37
|
end
|
38
|
+
|
39
|
+
# Determine if the current nav component is the active one by looking
|
40
|
+
# at the first part of the url against the href attribute.
|
41
|
+
def active_tab?
|
42
|
+
url.path.split('/')[1] == attrs.href.split('/')[1]
|
43
|
+
end
|
38
44
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'volt/extra_core/array'
|
3
|
+
|
4
|
+
class TestClassAttributes
|
5
|
+
class_attribute :some_data
|
6
|
+
end
|
7
|
+
|
8
|
+
class TestSubClassAttributes < TestClassAttributes
|
9
|
+
end
|
10
|
+
|
11
|
+
class TestSubClassAttributes2 < TestClassAttributes
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "extra_core class addons" do
|
15
|
+
it 'should provide class_attributes that can be inherited' do
|
16
|
+
expect(TestClassAttributes.some_data).to eq(nil)
|
17
|
+
|
18
|
+
TestClassAttributes.some_data = 5
|
19
|
+
expect(TestClassAttributes.some_data).to eq(5)
|
20
|
+
expect(TestSubClassAttributes.some_data).to eq(5)
|
21
|
+
expect(TestSubClassAttributes2.some_data).to eq(5)
|
22
|
+
|
23
|
+
TestSubClassAttributes.some_data = 10
|
24
|
+
expect(TestClassAttributes.some_data).to eq(5)
|
25
|
+
expect(TestSubClassAttributes.some_data).to eq(10)
|
26
|
+
expect(TestSubClassAttributes2.some_data).to eq(5)
|
27
|
+
|
28
|
+
TestSubClassAttributes2.some_data = 15
|
29
|
+
expect(TestClassAttributes.some_data).to eq(5)
|
30
|
+
expect(TestSubClassAttributes.some_data).to eq(10)
|
31
|
+
expect(TestSubClassAttributes2.some_data).to eq(15)
|
32
|
+
end
|
33
|
+
end
|
@@ -55,6 +55,26 @@ if ENV['BROWSER']
|
|
55
55
|
|
56
56
|
expect(page).to_not have_content('Test Account 9550')
|
57
57
|
end
|
58
|
+
|
59
|
+
it 'should fail to create an account without a valid email and password' do
|
60
|
+
visit '/'
|
61
|
+
|
62
|
+
click_link 'Login'
|
63
|
+
click_link 'Signup here'
|
64
|
+
|
65
|
+
expect(page).to_not have_content('must be at least 8 characters')
|
66
|
+
|
67
|
+
fields = all(:css, 'form .form-control')
|
68
|
+
|
69
|
+
fields[0].set('test')
|
70
|
+
fields[1].set('awe')
|
71
|
+
fields[2].set('Tes')
|
72
|
+
|
73
|
+
# some capybara drivers don't trigger blur correctly
|
74
|
+
page.execute_script("$('.form-control').blur()")
|
75
|
+
|
76
|
+
expect(page).to have_content('must be at least 8 characters')
|
77
|
+
end
|
58
78
|
end
|
59
79
|
|
60
80
|
end
|
@@ -50,7 +50,7 @@ describe Volt::TemplateBinding do
|
|
50
50
|
|
51
51
|
path, result = @template_binding.path_for_template('comments/new/errors')
|
52
52
|
expect(path).to eq('main/comments/new/errors')
|
53
|
-
expect(result).to eq(
|
53
|
+
expect(result).to eq(["main", "comments_controller", "errors"])
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'should handle a tripple lookup to controllers' do
|
data/spec/spec_helper.rb
CHANGED
@@ -16,4 +16,10 @@ class MainController < Volt::ModelController
|
|
16
16
|
def main_path
|
17
17
|
params._controller.or('main') + '/' + params._action.or('index')
|
18
18
|
end
|
19
|
+
|
20
|
+
# Determine if the current nav component is the active one by looking
|
21
|
+
# at the first part of the url against the href attribute.
|
22
|
+
def active_tab?
|
23
|
+
url.path.split('/')[1] == attrs.href.split('/')[1]
|
24
|
+
end
|
19
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -473,6 +473,7 @@ files:
|
|
473
473
|
- lib/volt/data_stores/mongo_driver.rb
|
474
474
|
- lib/volt/extra_core/array.rb
|
475
475
|
- lib/volt/extra_core/blank.rb
|
476
|
+
- lib/volt/extra_core/class.rb
|
476
477
|
- lib/volt/extra_core/extra_core.rb
|
477
478
|
- lib/volt/extra_core/inflections.rb
|
478
479
|
- lib/volt/extra_core/inflector.rb
|
@@ -611,6 +612,7 @@ files:
|
|
611
612
|
- spec/apps/kitchen_sink/config/base/index.html
|
612
613
|
- spec/controllers/reactive_accessors_spec.rb
|
613
614
|
- spec/extra_core/array_spec.rb
|
615
|
+
- spec/extra_core/class_spec.rb
|
614
616
|
- spec/extra_core/inflector_spec.rb
|
615
617
|
- spec/extra_core/object_spec.rb
|
616
618
|
- spec/extra_core/string_transformation_test_cases.rb
|
@@ -757,6 +759,7 @@ test_files:
|
|
757
759
|
- spec/apps/kitchen_sink/config/base/index.html
|
758
760
|
- spec/controllers/reactive_accessors_spec.rb
|
759
761
|
- spec/extra_core/array_spec.rb
|
762
|
+
- spec/extra_core/class_spec.rb
|
760
763
|
- spec/extra_core/inflector_spec.rb
|
761
764
|
- spec/extra_core/object_spec.rb
|
762
765
|
- spec/extra_core/string_transformation_test_cases.rb
|